using com.byt.suce.db.dao;
using System;
using System.Data;
using System.Data.Common;
using com.byt.webcore;
using System.Collections.Generic;
using MYLSOFT.JsonSimple;
using System.Data.SqlClient;

namespace com.byt.suce.db.mapper
{

    public class PkgEbxml : AbstractDataAccessObject, IPkgEbxml
    {

        public PkgEbxml()
        {
        }

        public PkgEbxml.AditivoInsertParam aditivoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.AditivoInsertParam param = newAditivoInsertParam(map);
            aditivoInsert(conn, param);
            return param;
        }

        public PkgEbxml.AditivoInsertParam aditivoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.AditivoInsertParam param = newAditivoInsertParam(json);
            aditivoInsert(conn, param);
            return param;
        }

        public PkgEbxml.AditivoInsertParam aditivoInsert(Connection conn)
        {
            PkgEbxml.AditivoInsertParam param = newAditivoInsertParam();
            aditivoInsert(conn, param);
            return param;
        }

        public void aditivoInsert(Connection conn, PkgEbxml.AditivoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_aditivo_insert";
            DbParameter par = null;
            // idaditivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idaditivo";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idaditivo == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idaditivo;
            // idproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;
            // descaditivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@descaditivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Descaditivo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Descaditivo;
            // pesoaditivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@pesoaditivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Pesoaditivo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Pesoaditivo;
            // sincodex
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@sincodex";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Sincodex))
                par.Value = DBNull.Value;
            else
                par.Value = param.Sincodex;
            // sustgrasa
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@sustgrasa";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Sustgrasa))
                par.Value = DBNull.Value;
            else
                par.Value = param.Sustgrasa;
            // itemaditivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@itemaditivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Itemaditivo == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Itemaditivo;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idaditivo"].Value))
                param.Idaditivo = null;
            else
                param.Idaditivo = (int?)cmd.Parameters["@idaditivo"].Value;
        }

        public PkgEbxml.AdjuntoInsertParam adjuntoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.AdjuntoInsertParam param = newAdjuntoInsertParam(map);
            adjuntoInsert(conn, param);
            return param;
        }

        public PkgEbxml.AdjuntoInsertParam adjuntoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.AdjuntoInsertParam param = newAdjuntoInsertParam(json);
            adjuntoInsert(conn, param);
            return param;
        }

        public PkgEbxml.AdjuntoInsertParam adjuntoInsert(Connection conn)
        {
            PkgEbxml.AdjuntoInsertParam param = newAdjuntoInsertParam();
            adjuntoInsert(conn, param);
            return param;
        }

        public void adjuntoInsert(Connection conn, PkgEbxml.AdjuntoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_adjunto_insert";
            DbParameter par = null;
            // idadjunto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idadjunto";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idadjunto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idadjunto;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            // fecarchivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fecarchivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            //par.Size = 500;
            if (string.IsNullOrEmpty(param.Fecarchivo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Fecarchivo;

            // nombarchivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombarchivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 500;
            if (string.IsNullOrEmpty(param.Nombarchivo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombarchivo;
            // nombarchivosistema
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombarchivosistema";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 500;
            if (string.IsNullOrEmpty(param.Nombarchivosistema))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombarchivosistema;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idadjunto"].Value))
                param.Idadjunto = null;
            else
                param.Idadjunto = (int?)cmd.Parameters["@idadjunto"].Value;
        }

        public PkgEbxml.AlmacenInsertParam almacenInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.AlmacenInsertParam param = newAlmacenInsertParam(map);
            almacenInsert(conn, param);
            return param;
        }

        public PkgEbxml.AlmacenInsertParam almacenInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.AlmacenInsertParam param = newAlmacenInsertParam(json);
            almacenInsert(conn, param);
            return param;
        }

        public PkgEbxml.AlmacenInsertParam almacenInsert(Connection conn)
        {
            PkgEbxml.AlmacenInsertParam param = newAlmacenInsertParam();
            almacenInsert(conn, param);
            return param;
        }

        public void almacenInsert(Connection conn, PkgEbxml.AlmacenInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_almacen_insert";
            DbParameter par = null;
            // almidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Almidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Almidpersona;
            // almnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Almnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almnombpersona;
            // almidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Almidtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Almidtipodocu;
            // almnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Almnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almnumedocumento;
            // almdirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almdirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Almdirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almdirepersona;
            // almidubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almidubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Almidubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almidubigeo;
            // almtelffijo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almtelffijo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Almtelffijo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almtelffijo;
            // almtelffax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almtelffax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Almtelffax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almtelffax;
            // almdireemail
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almdireemail";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Almdireemail))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almdireemail;
            // almdirereferencia
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@almdirereferencia";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Almdirereferencia))
                par.Value = DBNull.Value;
            else
                par.Value = param.Almdirereferencia;
            // repidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Repidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidpersona;
            // repnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnombpersona;
            // repidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Repidtipodocu))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidtipodocu;
            // repnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnumedocumento;
            // repdirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repdirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repdirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repdirepersona;


            /* MODIFICADO POR CESAR BOCANEGRA */

            //estbldepartamento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estbldepartamento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 6;
            if (string.IsNullOrEmpty(param.Estbldepartamento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estbldepartamento;

            //estblprovincia
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estblprovincia";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Estblprovincia))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estblprovincia;

            //estbldistrito
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estbldistrito";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Estbldistrito))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estbldistrito;

            //@idtipopersona2
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idtipopersona2";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idtipopersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idtipopersona;

            //@expplanta
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@expplanta";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Expedienteplanta))
                par.Value = DBNull.Value;
            else
                par.Value = param.Expedienteplanta;

            //@expplanta
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@resolp";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Resolucionplanta))
                par.Value = DBNull.Value;
            else
                par.Value = param.Resolucionplanta;


            /* FIN DE LA MODIFICACION */ 

            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@almidpersona"].Value))
                param.Almidpersona = null;
            else
                param.Almidpersona = (int?)cmd.Parameters["@almidpersona"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@repidpersona"].Value))
                param.Repidpersona = null;
            else
                param.Repidpersona = (int?)cmd.Parameters["@repidpersona"].Value;
        }

        public PkgEbxml.ComposicionInsertParam composicionInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.ComposicionInsertParam param = newComposicionInsertParam(map);
            composicionInsert(conn, param);
            return param;
        }

        public PkgEbxml.ComposicionInsertParam composicionInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.ComposicionInsertParam param = newComposicionInsertParam(json);
            composicionInsert(conn, param);
            return param;
        }

        public PkgEbxml.ComposicionInsertParam composicionInsert(Connection conn)
        {
            PkgEbxml.ComposicionInsertParam param = newComposicionInsertParam();
            composicionInsert(conn, param);
            return param;
        }

        public void composicionInsert(Connection conn, PkgEbxml.ComposicionInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_composicion_insert";
            DbParameter par = null;
            // idcomposicion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idcomposicion";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idcomposicion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idcomposicion;
            // idproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;
            // desccomposicion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@desccomposicion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 2000;

            //descorigcomposicion
            if (string.IsNullOrEmpty(param.Desccomposicion) && string.IsNullOrEmpty(param.Descorigcomposicion))
                par.Value = DBNull.Value;
            else
                par.Value = (string.IsNullOrEmpty(param.Desccomposicion) ? "" : param.Desccomposicion) + (string.IsNullOrEmpty(param.Descorigcomposicion) ? "" : param.Descorigcomposicion);

            // @descnuevcomposicion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@descnuevcomposicion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 2000;
            if (string.IsNullOrEmpty(param.Descnuevcomposicion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Descnuevcomposicion;
            // itemcomposicion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@itemcomposicion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 5;
            if (string.IsNullOrEmpty(param.Itemcomposicion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Itemcomposicion;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idcomposicion"].Value))
                param.Idcomposicion = null;
            else
                param.Idcomposicion = (int?)cmd.Parameters["@idcomposicion"].Value;
        }



        //FIN DE LA MODIFICACION

        /* para el caso especial de la DGS004 */
        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraIns(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam(map);
            empresaExtranjeraIns(conn, param);
            return param;
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraIns(Connection conn, JSONObject json)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam(json);
            empresaExtranjeraIns(conn, param);
            return param;
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraIns(Connection conn)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam();
            empresaExtranjeraIns(conn, param);
            return param;
        }

        public void empresaExtranjeraIns(Connection conn, PkgEbxml.EmpresaExtranjeraUpdateParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_INSERTA_EMPEXT";
            DbParameter par = null;

            //@RUC
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@RUC";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Numedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numedocumento;

            //@nombre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombpersona;

            //@direccion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direccion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direpersona;

            //@idpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersona;

            cmd.ExecuteNonQuery();

            if (DBNull.Value.Equals(cmd.Parameters["@idpersona"].Value))
                param.Idpersona = null;
            else
                param.Idpersona = (int?)cmd.Parameters["@idpersona"].Value;

        }
         /* FIN DE LA MODIFICACION */ 
        
        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraUpdate(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam(map);
            empresaExtranjeraUpdate(conn, param);
            return param;
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraUpdate(Connection conn, JSONObject json)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam(json);
            empresaExtranjeraUpdate(conn, param);
            return param;
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam empresaExtranjeraUpdate(Connection conn)
        {
            PkgEbxml.EmpresaExtranjeraUpdateParam param = newEmpresaExtranjeraUpdateParam();
            empresaExtranjeraUpdate(conn, param);
            return param;
        }

        public void empresaExtranjeraUpdate(Connection conn, PkgEbxml.EmpresaExtranjeraUpdateParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_empresa_extranjera_update";
            DbParameter par = null;
            // nombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombpersona;
            // direpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direpersona;
            // idpais
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpais";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idpais == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpais;
            // nombpais
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombpais";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Nombpais))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombpais;
            // nombautoridad
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombautoridad";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nombautoridad))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombautoridad;
            // idtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idtipodocu;
            // numedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Numedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numedocumento;
            // ubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@ubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Ubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Ubigeo;
            // telffijo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@telffijo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Telffijo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Telffijo;
            // telffax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@telffax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Telffax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Telffax;
            // direemail
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direemail";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Direemail))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direemail;
            // direreferencia
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direreferencia";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direreferencia))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direreferencia;
            // repnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnombpersona;
            // repidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Repidtipodocu))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidtipodocu;
            // repnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnumedocumento;
            // idtipopersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idtipopersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idtipopersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idtipopersona;
            // qaresp
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@qaresp";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Qaresp))
                par.Value = DBNull.Value;
            else
                par.Value = param.Qaresp;
            // repidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Repidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidpersona;
            // idpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersona;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@repidpersona"].Value))
                param.Repidpersona = null;
            else
                param.Repidpersona = (int?)cmd.Parameters["@repidpersona"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@idpersona"].Value))
                param.Idpersona = null;
            else
                param.Idpersona = (int?)cmd.Parameters["@idpersona"].Value;
        }

        public PkgEbxml.EnvaseInsertParam envaseInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.EnvaseInsertParam param = newEnvaseInsertParam(map);
            envaseInsert(conn, param);
            return param;
        }

        public PkgEbxml.EnvaseInsertParam envaseInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.EnvaseInsertParam param = newEnvaseInsertParam(json);
            envaseInsert(conn, param);
            return param;
        }

        public PkgEbxml.EnvaseInsertParam envaseInsert(Connection conn)
        {
            PkgEbxml.EnvaseInsertParam param = newEnvaseInsertParam();
            envaseInsert(conn, param);
            return param;
        }

        public void envaseInsert(Connection conn, PkgEbxml.EnvaseInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_envase_insert";
            DbParameter par = null;
            // idenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idenvase";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idenvase == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idenvase;
            // idproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;
            // tipoenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tipoenvase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Tipoenvase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tipoenvase;
            // mateenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@mateenvase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Mateenvase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Mateenvase;
            // capaenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@capaenvase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Capaenvase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Capaenvase;
            // itemenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@itemenvase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Itemenvase == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Itemenvase;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idenvase"].Value))
                param.Idenvase = null;
            else
                param.Idenvase = (int?)cmd.Parameters["@idenvase"].Value;
        }

        public PkgEbxml.LaboratorioInsertParam laboratorioInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.LaboratorioInsertParam param = newLaboratorioInsertParam(map);
            laboratorioInsert(conn, param);
            return param;
        }

        public PkgEbxml.LaboratorioInsertParam laboratorioInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.LaboratorioInsertParam param = newLaboratorioInsertParam(json);
            laboratorioInsert(conn, param);
            return param;
        }

        public PkgEbxml.LaboratorioInsertParam laboratorioInsert(Connection conn)
        {
            PkgEbxml.LaboratorioInsertParam param = newLaboratorioInsertParam();
            laboratorioInsert(conn, param);
            return param;
        }

        public void laboratorioInsert(Connection conn, PkgEbxml.LaboratorioInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_laboratorio_insert";
            DbParameter par = null;
            // perlabidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Perlabidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabidpersona;
            // perlabtelffijo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabtelffijo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Perlabtelffijo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabtelffijo;
            // perlabtelffax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabtelffax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Perlabtelffax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabtelffax;
            // perlabtelfcelular
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabtelfcelular";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Perlabtelfcelular))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabtelfcelular;
            // perlabnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Perlabnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabnumedocumento;
            // perlabnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Perlabnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabnombpersona;
            // perlabidubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabidubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Perlabidubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabidubigeo;
            // perlabidtipopersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabidtipopersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Perlabidtipopersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabidtipopersona;
            // perlabidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Perlabidtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabidtipodocu;
            // perlabdirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabdirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Perlabdirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabdirepersona;
            // perlabdireemail
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perlabdireemail";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Perlabdireemail))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perlabdireemail;
            // labidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Labidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Labidpersona;
            // labnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Labnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Labnumedocumento;
            // labnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Labnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Labnombpersona;
            // labidubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labidubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Labidubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Labidubigeo;
            // labidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Labidtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Labidtipodocu;
            // labdirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@labdirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Labdirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Labdirepersona;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@perlabidpersona"].Value))
                param.Perlabidpersona = null;
            else
                param.Perlabidpersona = (int?)cmd.Parameters["@perlabidpersona"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@labidpersona"].Value))
                param.Labidpersona = null;
            else
                param.Labidpersona = (int?)cmd.Parameters["@labidpersona"].Value;
        }

        public PkgEbxml.N8GetParam n8Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8GetParam param = newN8GetParam(map);
            n8Get(conn, param);
            return param;
        }

        public PkgEbxml.N8GetParam n8Get(Connection conn, JSONObject json)
        {
            PkgEbxml.N8GetParam param = newN8GetParam(json);
            n8Get(conn, param);
            return param;
        }

        public PkgEbxml.N8GetParam n8Get(Connection conn)
        {
            PkgEbxml.N8GetParam param = newN8GetParam();
            n8Get(conn, param);
            return param;
        }

        public void n8Get(Connection conn, PkgEbxml.N8GetParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_N8_get";
            DbParameter par = null;
            // iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;
            // estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;
            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;
            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;
            // cur_petitioner
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_petitioner";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_specific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_factory
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_factory";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_storage
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_storage";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            // cur_laboratory
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_laboratory";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            // cur_products
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_products";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;
            param.CurPetitioner = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurSpecific = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurFactory = (DbDataReader)ds.Tables[2].CreateDataReader();// MODIF CESAR BOCANEGRA *** EN EL EJ ESTA TABLA ESTA VACIA, LO QUE GENERA ERROR
            param.CurStorage = (DbDataReader)ds.Tables[3].CreateDataReader();
            param.CurLaboratory = (DbDataReader)ds.Tables[4].CreateDataReader();
            param.CurProducts = (DbDataReader)ds.Tables[5].CreateDataReader();
        }

        /* MODIFICADO POR CESAR BOCANEGRA */

        //DGS004

        public PkgEbxml.N8dgs004GetParam n8dgs004Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8dgs004GetParam param = newN8dgs004GetParam(map);
            n8dgs004Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs004GetParam n8dgs004Get(Connection conn, JSONObject json)
        {
            PkgEbxml.N8dgs004GetParam param = newN8dgs004GetParam(json);
            n8dgs004Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs004GetParam n8dgs004Get(Connection conn)
        {
            PkgEbxml.N8dgs004GetParam param = newN8dgs004GetParam();
            n8dgs004Get(conn, param);
            return param;
        }

        public void n8dgs004Get(Connection conn, N8dgs004GetParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "EBX_N8DGS004_get";
            DbParameter par = null;

            //iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;

            //estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;

            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;

            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;

            //@cur_specific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@cur_petitioner
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_petitioner";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@curSanitaryRegisterH
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@curSanitaryRegisterH";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@curProductDest
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@curProductDest";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@curSanitaryRegister
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@curSanitaryRegister";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);

            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;

            param.CurSpecific = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurPetitioner = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurSanitaryRegisterH = (DbDataReader)ds.Tables[2].CreateDataReader();
            param.CurProductDest = (DbDataReader)ds.Tables[3].CreateDataReader();
            param.CurSanitaryRegister = (DbDataReader)ds.Tables[4].CreateDataReader();

        }

        public PkgEbxml.N8dgs003GetParam n8dgs003Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8dgs003GetParam param = newN8dgs003GetParam(map);
            n8dgs003Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs003GetParam n8dgs003Get(Connection conn,  JSONObject json)
        {
            PkgEbxml.N8dgs003GetParam param = newN8dgs003GetParam(json);
            n8dgs003Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs003GetParam n8dgs003Get(Connection conn)
        {
            PkgEbxml.N8dgs003GetParam param = newN8dgs003GetParam();
            n8dgs003Get(conn, param);
            return param;
        }

        public void n8dgs003Get(Connection conn, N8dgs003GetParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "EBX_N8DGS003_GET";
            DbParameter par = null;

            //iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;

            //estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;

            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;

            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;

            //@cur_specific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@cur_Petitioner
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_Petitioner";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@cur_StorageLocation
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_StorageLocation";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@cur_SanitaryRegEstb
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_SanitaryRegEstb";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //@cur_SanitaryRegProd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_SanitaryRegProd";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

          /*  //@cur_Adjuntos
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_Adjuntos";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            */
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;
            
            param.CurSpecific = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurPetitioner = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurStorageLocation = (DbDataReader)ds.Tables[2].CreateDataReader();
            param.CurSanitaryRegisterEs = (DbDataReader)ds.Tables[3].CreateDataReader();
            param.CurSanitaryRegisterPd = (DbDataReader)ds.Tables[4].CreateDataReader();
           // param.CurAdjuntos = (DbDataReader)ds.Tables[5].CreateDataReader();
        }

        /* FIN DE LA MODIFICACION */


        /* MODIFICADO POR CESAR BOCANEGRA */

        public PkgEbxml.N8dgs002GetParam n8dgs002Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8dgs002GetParam param = newN8dgs002GetParam(map);
            n8dgs002Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs002GetParam n8dgs002Get(Connection conn, JSONObject json)
        {
            PkgEbxml.N8dgs002GetParam param = newN8dgs002GetParam(json);
            n8dgs002Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs002GetParam n8dgs002Get(Connection conn)
        {
            PkgEbxml.N8dgs002GetParam param = newN8dgs002GetParam();
            n8dgs002Get(conn, param);
            return param;
        }

        public void n8dgs002Get(Connection conn, PkgEbxml.N8dgs002GetParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_N8DGS002_get";
            DbParameter par = null;

            //iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;

            //estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;

            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;

            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;

            //curspecific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //cur_establishment
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_establishment";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //cur_productdestination
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_productdestination";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            //cur_foodDrink
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_foodDrink";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;
            param.CurSpecific = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurEstablishment = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurProductDestination = (DbDataReader)ds.Tables[2].CreateDataReader();
            param.CurFoodDrink = (DbDataReader)ds.Tables[3].CreateDataReader();

        }

        /* FIN DE LA MODIFICACION */

        public PkgEbxml.N8dgs009GetParam n8dgs009Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8dgs009GetParam param = newN8dgs009GetParam(map);
            n8dgs009Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs009GetParam n8dgs009Get(Connection conn, JSONObject json)
        {
            PkgEbxml.N8dgs009GetParam param = newN8dgs009GetParam(json);
            n8dgs009Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs009GetParam n8dgs009Get(Connection conn)
        {
            PkgEbxml.N8dgs009GetParam param = newN8dgs009GetParam();
            n8dgs009Get(conn, param);
            return param;
        }

        public void n8dgs009Get(Connection conn, PkgEbxml.N8dgs009GetParam param)
        {

            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_N8DGS009_get";
            DbParameter par = null;
            // iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;
            // estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;
            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;
            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;
            // cur_petitioner
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_petitioner";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_specific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_factory
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_factory";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_products
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_products";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_storage
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_storage";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;

            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;
            param.CurPetitioner = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurSpecific = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurFactory = (DbDataReader)ds.Tables[2].CreateDataReader();
            param.CurProducts = (DbDataReader)ds.Tables[3].CreateDataReader();
            param.CurStorage = (DbDataReader)ds.Tables[4].CreateDataReader();
 
        }


        public PkgEbxml.N8dgs006GetParam n8dgs006Get(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.N8dgs006GetParam param = newN8dgs006GetParam(map);
            n8dgs006Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs006GetParam n8dgs006Get(Connection conn, JSONObject json)
        {
            PkgEbxml.N8dgs006GetParam param = newN8dgs006GetParam(json);
            n8dgs006Get(conn, param);
            return param;
        }

        public PkgEbxml.N8dgs006GetParam n8dgs006Get(Connection conn)
        {
            PkgEbxml.N8dgs006GetParam param = newN8dgs006GetParam();
            n8dgs006Get(conn, param);
            return param;
        }

        public void n8dgs006Get(Connection conn, PkgEbxml.N8dgs006GetParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_N8DGS006_get";
            DbParameter par = null;
            // iddr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Iddr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Iddr;
            // estado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@estado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estado;
            // xmlns
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xmlns";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 100;
            if (string.IsNullOrEmpty(param.Xmlns))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xmlns;
            // xsd
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@xsd";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Xsd))
                par.Value = DBNull.Value;
            else
                par.Value = param.Xsd;
            // cur_petitioner
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_petitioner";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_specific
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_specific";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_factory
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_factory";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            // cur_products
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_products";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            if (DBNull.Value.Equals(cmd.Parameters["@xmlns"].Value))
                param.Xmlns = null;
            else
                param.Xmlns = (string)cmd.Parameters["@xmlns"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@xsd"].Value))
                param.Xsd = null;
            else
                param.Xsd = (string)cmd.Parameters["@xsd"].Value;
            param.CurPetitioner = (DbDataReader)ds.Tables[0].CreateDataReader();
            param.CurSpecific = (DbDataReader)ds.Tables[1].CreateDataReader();
            param.CurFactory = (DbDataReader)ds.Tables[2].CreateDataReader();
            param.CurProducts = (DbDataReader)ds.Tables[3].CreateDataReader();
        }

        public PkgEbxml.PersonaUpdateParam personaUpdate(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.PersonaUpdateParam param = newPersonaUpdateParam(map);
            personaUpdate(conn, param);
            return param;
        }

        public PkgEbxml.PersonaUpdateParam personaUpdate(Connection conn, JSONObject json)
        {
            PkgEbxml.PersonaUpdateParam param = newPersonaUpdateParam(json);
            personaUpdate(conn, param);
            return param;
        }

        public PkgEbxml.PersonaUpdateParam personaUpdate(Connection conn)
        {
            PkgEbxml.PersonaUpdateParam param = newPersonaUpdateParam();
            personaUpdate(conn, param);
            return param;
        }

        public void personaUpdate(Connection conn, PkgEbxml.PersonaUpdateParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_persona_update";
            DbParameter par = null;
            // idpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersona;
            // nombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombpersona;
            // idtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idtipodocu;
            // numedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Numedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numedocumento;
            // direpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direpersona;
            // direreferencia
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direreferencia";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direreferencia))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direreferencia;
            // idubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Idubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Idubigeo;
            // telffijo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@telffijo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Telffijo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Telffijo;
            // telfcelular
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@telfcelular";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Telfcelular))
                par.Value = DBNull.Value;
            else
                par.Value = param.Telfcelular;
            // telffax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@telffax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Telffax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Telffax;
            // direemail
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direemail";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Direemail))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direemail;
            // idtipopersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idtipopersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idtipopersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idtipopersona;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idpersona"].Value))
                param.Idpersona = null;
            else
                param.Idpersona = (int?)cmd.Parameters["@idpersona"].Value;
        }

        //modificado por CESAR BOCANEGRA

        /* MODIFICADO POR CESAR BOCANEGRA */

        public PkgEbxml.TitularCertificadoParam TitularCertificado(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.TitularCertificadoParam param = newTitularCertificadoParam(map);
            TitularCertificado(conn, param);
            return param;
        }

        public PkgEbxml.TitularCertificadoParam TitularCertificado(Connection conn, JSONObject json)
        {
            PkgEbxml.TitularCertificadoParam param = newTitularCertificadoParam(json);
            TitularCertificado(conn, param);
            return param;
        }

        public PkgEbxml.TitularCertificadoParam TitularCertificado(Connection conn)
        {
            PkgEbxml.TitularCertificadoParam param = newTitularCertificadoParam();
            TitularCertificado(conn, param);
            return param;
        }

        public void TitularCertificado(Connection conn, PkgEbxml.TitularCertificadoParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_INSERTA_TITULAR";
            DbParameter par = null;

            //@idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            //@idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            //@nomtitu varchar(250),
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomtitu";
            par.Direction = ParameterDirection.Input;
            par.DbType=DbType.String;
            par.Size=250;
            if (string.IsNullOrEmpty(param.Nomtitucertificado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nomtitucertificado;

            //@proced
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@proced";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 4;
            /* VUCE ESTA ENVIANDO LOS DATOS AL REVEZ CODIGO COMO NOMBRE Y NOMBRE VACIO, SACAR EL COMENTARIO
             * CUANDO ESTE CORREGIDO*/
            /*
            if (string.IsNullOrEmpty(param.Procpaisorigen))
                par.Value = DBNull.Value;
            else
                par.Value = param.Procpaisorigen;
            */
            if (string.IsNullOrEmpty(param.Paisorigen))
                par.Value = DBNull.Value;
            else
                par.Value = param.Paisorigen;

            //@paisorigen
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@paisorigen";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;

            /* VUCE ESTA ENVIANDO LOS DATOS AL REVEZ CODIGO COMO NOMBRE Y NOMBRE VACIO, SACAR EL COMENTARIO
             * CUANDO ESTE CORREGIDO*/
            /*
            if (string.IsNullOrEmpty(param.Paisorigen))
                par.Value = DBNull.Value;
            else
                par.Value = param.Paisorigen;
            */

            if (string.IsNullOrEmpty(param.Procpaisorigen))
                par.Value = DBNull.Value;
            else
                par.Value = param.Procpaisorigen;

            //@nrocertificado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nrocertificado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 30;
            if (string.IsNullOrEmpty(param.Numecertif))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numecertif;

            //@repidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidpersona";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.Repidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidpersona;

            //@idpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersona";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.Idpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersona;

            cmd.ExecuteNonQuery();

            foreach (JSONObject jo in param.Jsonproductos)
            {
                //DbCommand cmd1;
                cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "[dbo].EBX_producto_insert";
                par = null;

                //@idproducto
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "idproducto";
                par.Direction = ParameterDirection.Output;
                par.DbType = DbType.Int32;
                par.Value = DBNull.Value;

                //@idsolicitud
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@idsolicitud";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                par.Value = param.Idsolicitud;

                //@idversion
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@idversion";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                par.Value = param.Idversion;

                //@numeitem
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@numeitem";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                par.Value =int.Parse(jo["itemvuce"].ToString());

                //@idsubpartida
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@idsubpartida";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 20;
                par.Value = (string)jo["coddetpartida"].ToString();

                //@nombproducto
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@nombproducto";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 2000;
                par.Value = (string)jo["nomprod"].ToString();

                //@marcproducto
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@marcproducto";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 300;
                par.Value = DBNull.Value;

                //@condconsalma
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@condconsalma";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 250;
                par.Value = DBNull.Value;

                //@perivida
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@perivida";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 50;
                par.Value = (string)jo["vidautil"].ToString();

                //@sistlote
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@sistlote";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 150;
                par.Value = DBNull.Value;

                //@codipartida
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@codipartida";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 20;
                par.Value = (string)jo["parsunat"].ToString();

                //@contaditivo
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@contaditivo";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 1;
                par.Value = DBNull.Value;

                //@codiclase
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@codiclase";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 10;
                par.Value = DBNull.Value;

                //@nombclase
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@nombclase";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 250;
                par.Value = DBNull.Value;

                //@codigrupo
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@codigrupo";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 10;
                par.Value = DBNull.Value;

                //@autosanitaria
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@autosanitaria";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 250;
                par.Value = DBNull.Value;

                //@registrosanitario
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@registrosanitario";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 50;
                par.Value = (string)jo["codregsanitario"].ToString();

                //@cancelaproducto
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@cancelaproducto";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 1;
                par.Value = DBNull.Value;

                //@activoproducto
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@activoproducto";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                par.Size = 1;
                par.Value = DBNull.Value;

                cmd.ExecuteNonQuery();

                cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "EBX_UPDATE_PRODXFECH";
                par = null;

                //@idsolicitud
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@idsolicitud";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                par.Value = param.Idsolicitud;

                //@idversion
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@idversion";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                par.Value = param.Idversion;

                //@femision
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@femision";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.DateTime;
                /*
                if (param.Emisioncertif == null)
                    par.Value = DBNull.Value;
                else
                    par.Value = param.Emisioncertif;
                */
                if (string.IsNullOrEmpty((string)jo["emisioncertif"]))
                    par.Value = DBNull.Value;
                else
                    par.Value = DateTime.Parse((string)jo["emisioncertif"]);
                

                //@ffin
                par = cmd.CreateParameter();
                cmd.Parameters.Add(par);
                par.ParameterName = "@ffin";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.DateTime;
                /*
                if (param.Fincertif == null)
                    par.Value = DBNull.Value;
                else
                    par.Value = param.Fincertif;
                */
                if (string.IsNullOrEmpty((string)jo["fincertif"]))
                    par.Value = DBNull.Value;
                else
                    par.Value = DateTime.Parse((string)jo["fincertif"]);
                cmd.ExecuteNonQuery();



            }

            

        }

        /* FIN DE LA MODIFICACION */


        public PkgEbxml.ProductoInsertParam ProductoInsertDet(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam(map);
            ProductoInsertDet(conn, param);
            return param;
        }

        public PkgEbxml.ProductoInsertParam ProductoInsertDet(Connection conn, JSONObject json)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam(json);
            ProductoInsertDet(conn, param);
            return param;
        }

        public PkgEbxml.ProductoInsertParam ProductoInsertDet(Connection conn)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam();
            ProductoInsertDet(conn, param);
            return param;
        }

        public void ProductoInsertDet(Connection conn, PkgEbxml.ProductoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_PRODXDETALLE";
            DbParameter par = null;

            //@idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            //@idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            //@idproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;

            //@item
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@item";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Numeitem == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Numeitem;

            //@nomprod
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomprod";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 2000;
            if (string.IsNullOrEmpty(param.Nombproducto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombproducto;

            //@regsanit
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@regsanit";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Registrosanitario))
                par.Value = DBNull.Value;
            else
                par.Value = param.Registrosanitario;

            //@numecertif
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numecertif";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Numecertif))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numecertif;

            //@emisioncertif
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@emisioncertif";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Date;
            if (param.Emisioncertif == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Emisioncertif;

            //@fincertif
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fincertif";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Date;
            if (param.Fincertif == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fincertif;

            //@fabricante
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fabricante";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Nomfabricante))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nomfabricante;

            //@vidau
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@vidau";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Perivida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perivida;

            //@codpartida
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codpartida";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Codipartida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codipartida;

            //@codsubpar
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codsubpar";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Idsubpartida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsubpartida;

            //@um
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@um";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Decimal;
            if (param.Measureunit == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Measureunit;

            //@cantidad
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cantidad";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Decimal;
            if (param.Pquantity == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Pquantity;

            cmd.ExecuteNonQuery();


        }

        public PkgEbxml.ProductoInsertParam productoInsertDetalle(Connection conn, Dictionary<string, string> map)
        {
             PkgEbxml.ProductoInsertParam param = newProductoInsertParam(map);
             productoInsert(conn, param);
             return param;
        }

        public PkgEbxml.ProductoInsertParam productoInsertDetalle(Connection conn, JSONObject json)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam(json);
            productoInsert(conn, param);
            return param;
        }

        public PkgEbxml.ProductoInsertParam productoInsertDetalle(Connection conn)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam();
            productoInsert(conn, param);
            return param;
        }

        public void productoInsertDetalle(Connection conn, PkgEbxml.ProductoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_producto_detalle_insert";
            DbParameter par = null;

            //id del producto autogenerado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;

            //idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            //idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            //item se genera fuera de este metodo
            par=cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@item";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Numeitem == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Numeitem;

            //nombre del producto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@descrip_producto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Descrip_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Descrip_producto;

            //nombre cientifico
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomcient";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Nom_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nom_producto;

            //tipo de embalaje
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@TIPO_EMB";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Embalaje_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Embalaje_producto;

            //cantidad embalada
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@CANT_EMB";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Cant_embalada))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cant_embalada;

            //presentacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@PRESENT";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Pres_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Pres_producto;

            //peso neto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@PESON";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Pneto_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Pneto_producto;

            //peso bruto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@PESOB";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Pbruto_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Pbruto_producto;

            //temperatura almacenamiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@TEMPALMA";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Temp_alma_producto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Temp_alma_producto;

            //fecha de vencimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@FECHVENCE";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            par.Value = DBNull.Value;
            /*
            if (param.Fech_vence_producto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fech_vence_producto;
            */
            //nro de contenedor
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@NROCONT";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 30;
            if (string.IsNullOrEmpty(param.Nro_contenedor))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nro_contenedor;

            //nro factura
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@NROFACT";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 30;
            if (string.IsNullOrEmpty(param.Factura_comercial))
                par.Value = DBNull.Value;
            else
                par.Value = param.Factura_comercial;

            //nombre de la embarcacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@BARCO";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 30;
            if (string.IsNullOrEmpty(param.Nom_embarque))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nom_embarque;

            //lote
            /*
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@LOTE";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 30;
            if (string.IsNullOrEmpty(param.Nrolote))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nrolote;

            //fecha de produccion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@FCHPROD";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            if (param.Fech_produccion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fech_produccion;
            */
            cmd.ExecuteNonQuery();

            if (DBNull.Value.Equals(cmd.Parameters["@idproducto"].Value))
                param.Idproducto = null;
            else
                param.Idproducto = (int?)cmd.Parameters["@idproducto"].Value;

            DbCommand cmd1;
            //cmd1.CommandText = "EBX_PRODUCTO_LOTE_INSERT";
            //cmd1.CommandType = CommandType.StoredProcedure;
            string lote;
            DateTime? fechprod, fechvenci;

            foreach (JSONObject fila in param.Detalle)
            {
                //DbCommand cmd1 = conn.CreateCommand();
                cmd1 = conn.CreateCommand();
                cmd1.CommandText = "EBX_PRODUCTO_LOTE_INSERT";
                cmd1.CommandType = CommandType.StoredProcedure;

                lote = (string)fila["nrolote"];
                //fechprod = DateTime.Parse((string)fila["fech_produccion"]);
                fechprod = ResourceManager.parseDate((string)fila["fech_produccion"]);
                //fechvenci = ResourceManager.parseDate((string)fila["fech_venci"]); original
                fechvenci = ResourceManager.parseDate((string)fila["fech_vence_producto"]);
                //fechvenci = DateTime.Parse((string)fila["fech_venci"]);
                
                //el id del producto
                par = cmd1.CreateParameter();
                cmd1.Parameters.Add(par);
                par.ParameterName = "@idproducto";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.Int32;
                if (param.Idproducto == null)
                    par.Value = DBNull.Value;
                else
                    par.Value = param.Idproducto;

                 //el nro de lote
                par = cmd1.CreateParameter();
                cmd1.Parameters.Add(par);
                par.ParameterName = "@lote";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.String;
                if (lote == null || lote=="")
                    par.Value = DBNull.Value;
                else
                    par.Value = lote;

                // la fecha de produccion
                par = cmd1.CreateParameter();
                cmd1.Parameters.Add(par);
                par.ParameterName = "@fechprod";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.DateTime;
                if (fechprod == null)
                    par.Value = DBNull.Value;
                else
                    par.Value = fechprod;

                // la fecha de vencimiento
                par = cmd1.CreateParameter();
                cmd1.Parameters.Add(par);
                par.ParameterName = "@fechvenci";
                par.Direction = ParameterDirection.Input;
                par.DbType = DbType.DateTime;
                if (fechvenci == null)
                    par.Value = DBNull.Value;
                else
                    par.Value = fechvenci;

                cmd1.ExecuteNonQuery();
                
            }



        }

        //FIN DE LA MODIFICACION




        public PkgEbxml.ProductoInsertParam productoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam(map);
            productoInsert(conn, param);
            return param;
        }

        public PkgEbxml.ProductoInsertParam productoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam(json);
            productoInsert(conn, param);
            return param;
        }

        public PkgEbxml.ProductoInsertParam productoInsert(Connection conn)
        {
            PkgEbxml.ProductoInsertParam param = newProductoInsertParam();
            productoInsert(conn, param);
            return param;
        }

        public void productoInsert(Connection conn, PkgEbxml.ProductoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_producto_insert";
            DbParameter par = null;
            // idproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idproducto";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idproducto == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idproducto;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // numeitem
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numeitem";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Numeitem == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Numeitem;
            // idsubpartida
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsubpartida";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Idsubpartida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsubpartida;
            // nombproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 2000;
            if (string.IsNullOrEmpty(param.Nombproducto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombproducto;

            // nombproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@denominacioncomercial";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 4000;
            if (string.IsNullOrEmpty(param.Denominacioncomercial))
                par.Value = DBNull.Value;
            else
                par.Value = param.Denominacioncomercial;

            // marcproducto
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@marcproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 300;
            if (string.IsNullOrEmpty(param.Marcproducto))
                par.Value = DBNull.Value;
            else
                par.Value = param.Marcproducto;
            // condconsalma
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@condconsalma";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Condconsalma))
                par.Value = DBNull.Value;
            else
                par.Value = param.Condconsalma;
            // perivida
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@perivida";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Perivida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Perivida;
            // sistlote
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@sistlote";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 150;
            if (string.IsNullOrEmpty(param.Sistlote))
                par.Value = DBNull.Value;
            else
                par.Value = param.Sistlote;
            // codipartida
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codipartida";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Codipartida))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codipartida;
            // contaditivo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@contaditivo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Contaditivo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Contaditivo;
            // codiclase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codiclase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Codiclase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codiclase;
            // nombclase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombclase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nombclase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombclase;
            // codigrupo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codigrupo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Codigrupo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codigrupo;
            // autosanitaria
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@autosanitaria";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Autosanitaria))
                par.Value = DBNull.Value;
            else
                par.Value = param.Autosanitaria;
            // registrosanitario
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@registrosanitario";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Registrosanitario))
                par.Value = DBNull.Value;
            else
                par.Value = param.Registrosanitario;
            // cancelaregistro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cancelaproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Cancelaregistro))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cancelaregistro;
            // estadoregistro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@activoproducto";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Estadoregistro))
                par.Value = DBNull.Value;
            else
                par.Value = param.Estadoregistro;

            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idproducto"].Value))
                param.Idproducto = null;
            else
                param.Idproducto = (int?)cmd.Parameters["@idproducto"].Value;
        }

        public PkgEbxml.SolicitanteInsertParam solicitanteInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitanteInsertParam param = newSolicitanteInsertParam(map);
            solicitanteInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitanteInsertParam solicitanteInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitanteInsertParam param = newSolicitanteInsertParam(json);
            solicitanteInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitanteInsertParam solicitanteInsert(Connection conn)
        {
            PkgEbxml.SolicitanteInsertParam param = newSolicitanteInsertParam();
            solicitanteInsert(conn, param);
            return param;
        }

        public void solicitanteInsert(Connection conn, PkgEbxml.SolicitanteInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitante_insert";
            DbParameter par = null;
            // solidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Solidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Solidpersona;
            // solnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Solnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Solnombpersona;
            // solidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Solidtipodocu == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Solidtipodocu;
            // solnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Solnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Solnumedocumento;
            // soldirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soldirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Soldirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soldirepersona;
            // solidubigeo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solidubigeo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Solidubigeo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Solidubigeo;
            // soltelffijo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soltelffijo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Soltelffijo))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soltelffijo;
            // soltelffax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soltelffax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Soltelffax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soltelffax;
            // soldireemail
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soldireemail";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 200;
            if (string.IsNullOrEmpty(param.Soldireemail))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soldireemail;
            // soltelfcelular
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soltelfcelular";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Soltelfcelular))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soltelfcelular;
            // solidtipopersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@solidtipopersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Solidtipopersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Solidtipopersona;
            // soldirereferencia
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soldirereferencia";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Soldirereferencia))
                par.Value = DBNull.Value;
            else
                par.Value = param.Soldirereferencia;
            // repidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Repidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidpersona;
            // repnombpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnombpersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnombpersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnombpersona;
            // repidtipodocu
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repidtipodocu";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Repidtipodocu))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repidtipodocu;
            // repnumedocumento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repnumedocumento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repnumedocumento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repnumedocumento;
            // repdirepersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@repdirepersona";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Repdirepersona))
                par.Value = DBNull.Value;
            else
                par.Value = param.Repdirepersona;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@solidpersona"].Value))
                param.Solidpersona = null;
            else
                param.Solidpersona = (int?)cmd.Parameters["@solidpersona"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@repidpersona"].Value))
                param.Repidpersona = null;
            else
                param.Repidpersona = (int?)cmd.Parameters["@repidpersona"].Value;
        }



        public PkgEbxml.SolicitanteCambioInsertParam solicitantecambioInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitanteCambioInsertParam param = newSolicitanteCambioInsertParam(map);
            solicitantecambioInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitanteCambioInsertParam solicitantecambioInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitanteCambioInsertParam param = newSolicitanteCambioInsertParam(json);
            solicitantecambioInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitanteCambioInsertParam solicitantecambioInsert(Connection conn)
        {
            PkgEbxml.SolicitanteCambioInsertParam param = newSolicitanteCambioInsertParam();
            solicitantecambioInsert(conn, param);
            return param;
        }

        public void solicitantecambioInsert(Connection conn, PkgEbxml.SolicitanteCambioInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitantecambio_insert";
            DbParameter par = null;
            // cambidpersona
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambidpersona";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Cambidpersona == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambidpersona;
            // cambempresa
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambempresa";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Cambempresa))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambempresa;
            // cambdireccion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambdireccion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Cambdireccion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambdireccion;
            // cambtelefono
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambtelefono";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Cambtelefono))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambtelefono;
            // cambfax
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambfax";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Cambfax))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambfax;



            // cambidpersonarepre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambidpersonarepre";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Cambidpersonarepre == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambidpersonarepre;
            // cambtdocumentorepre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambtdocumentorepre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Cambtdocumentorepre))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambtdocumentorepre;
            // cambndocumentorepre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambndocumentorepre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 15;
            if (string.IsNullOrEmpty(param.Cambndocumentorepre))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambndocumentorepre;
            // cambnombrerepre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambnombrerepre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Cambnombrerepre))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambnombrerepre;
            // cambdireccionrepre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cambdireccionrepre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Cambdireccionrepre))
                par.Value = DBNull.Value;
            else
                par.Value = param.Cambdireccionrepre;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@cambidpersona"].Value))
                param.Cambidpersona = null;
            else
                param.Cambidpersona = (int?)cmd.Parameters["@cambidpersona"].Value;
            if (DBNull.Value.Equals(cmd.Parameters["@cambidpersonarepre"].Value))
                param.Cambidpersonarepre = null;
            else
                param.Cambidpersonarepre = (int?)cmd.Parameters["@cambidpersonarepre"].Value;
        }

        

        public PkgEbxml.SolicitudBorrarVersionParam solicitudBorrarVersion(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitudBorrarVersionParam param = newSolicitudBorrarVersionParam(map);
            solicitudBorrarVersion(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudBorrarVersionParam solicitudBorrarVersion(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitudBorrarVersionParam param = newSolicitudBorrarVersionParam(json);
            solicitudBorrarVersion(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudBorrarVersionParam solicitudBorrarVersion(Connection conn)
        {
            PkgEbxml.SolicitudBorrarVersionParam param = newSolicitudBorrarVersionParam();
            solicitudBorrarVersion(conn, param);
            return param;
        }

        public void solicitudBorrarVersion(Connection conn, PkgEbxml.SolicitudBorrarVersionParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitud_borrar_version";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            cmd.ExecuteNonQuery();
        }

        public PkgEbxml.SolicitudCrearVersionParam solicitudCrearVersion(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitudCrearVersionParam param = newSolicitudCrearVersionParam(map);
            solicitudCrearVersion(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudCrearVersionParam solicitudCrearVersion(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitudCrearVersionParam param = newSolicitudCrearVersionParam(json);
            solicitudCrearVersion(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudCrearVersionParam solicitudCrearVersion(Connection conn)
        {
            PkgEbxml.SolicitudCrearVersionParam param = newSolicitudCrearVersionParam();
            solicitudCrearVersion(conn, param);
            return param;
        }

        public void solicitudCrearVersion(Connection conn, PkgEbxml.SolicitudCrearVersionParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitud_crear_version";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // tipodoc
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tipodoc";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Tipodoc))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tipodoc;
            // numedoc
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numedoc";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Numedoc))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numedoc;
            // fechrecepcion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fechrecepcion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            if (param.Fechrecepcion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fechrecepcion;
            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idversion"].Value))
                param.Idversion = null;
            else
                param.Idversion = (int?)cmd.Parameters["@idversion"].Value;
        }

        public PkgEbxml.SolicitudInsertParam solicitudInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitudInsertParam param = newSolicitudInsertParam(map);
            solicitudInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudInsertParam solicitudInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitudInsertParam param = newSolicitudInsertParam(json);
            solicitudInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudInsertParam solicitudInsert(Connection conn)
        {
            PkgEbxml.SolicitudInsertParam param = newSolicitudInsertParam();
            solicitudInsert(conn, param);
            return param;
        }

        public void solicitudInsert(Connection conn, PkgEbxml.SolicitudInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitud_insert";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // codiformato
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codiformato";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Codiformato))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codiformato;
            // tipodoc
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tipodoc";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Tipodoc))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tipodoc;
            // numedoc
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@numedoc";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Numedoc))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numedoc;
            // idperssoli
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idperssoli";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idperssoli == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idperssoli;
            // idpersrepr
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersrepr";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idpersrepr == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersrepr;
            // idemprext
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idemprext";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idemprext == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idemprext;
            // idpersalma
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersalma";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idpersalma == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersalma;
            // idpersrepralma
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersrepralma";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idpersrepralma == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersrepralma;
            // fechrecepcion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fechrecepcion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            if (param.Fechrecepcion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fechrecepcion;
            // idperslab
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idperslab";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idperslab == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idperslab;
            // idpersperlab
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idpersperlab";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idpersperlab == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idpersperlab;

            //MODIFICADO POR CESAR BOCANEGRA

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idexpeditor";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Id_expedidor == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Id_expedidor;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@iddestinatario";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Id_destina == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Id_destina;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsoldestino";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Sol_destino == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Sol_destino;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idestableci";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Id_estableci == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Id_estableci;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@chgper";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Chgsoli == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Chgsoli;

            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@chgrepreper";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Chgrepresoli == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Chgrepresoli;

            //FIN DE LA MODIFICACION

            cmd.ExecuteNonQuery();
            if (DBNull.Value.Equals(cmd.Parameters["@idversion"].Value))
                param.Idversion = null;
            else
                param.Idversion = (int?)cmd.Parameters["@idversion"].Value;
        }


        public PkgEbxml.SolicitudEspecificacionInsertParam solicitudespecificacionInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitudEspecificacionInsertParam param = newSolicitudEspecificacionInsertParam(map);
            solicitudespecificacionInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudEspecificacionInsertParam solicitudespecificacionInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitudEspecificacionInsertParam param = newSolicitudEspecificacionInsertParam(json);
            solicitudespecificacionInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudEspecificacionInsertParam solicitudespecificacionInsert(Connection conn)
        {
            PkgEbxml.SolicitudEspecificacionInsertParam param = newSolicitudEspecificacionInsertParam();
            solicitudespecificacionInsert(conn, param);
            return param;
        }

        public void solicitudespecificacionInsert(Connection conn, PkgEbxml.SolicitudEspecificacionInsertParam param)
        {
            DbCommand cmd;
            DbParameter par = null;
            //obteniendo cadena de idiomas
            JSONArray ja = new JSONArray();

            string cadena=null;

            ja = param.Idioma;

            if (ja != null)
            {
                foreach (JSONObject jo in ja)
                {
                    par = null;
                    cmd = conn.CreateCommand();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "EBX_IDIOMA";

                    //vuce envia invertidos los parametros, sacar el comentario cuando este corregido
                    /*
                    par = cmd.CreateParameter();
                    cmd.Parameters.Add(par);
                    par.ParameterName = "@codidioma";
                    par.Direction = ParameterDirection.Input;
                    par.DbType = DbType.Int32;
                    if (jo["itemidioma"] == null)
                        par.Value = DBNull.Value;
                    else
                        par.Value =jo["itemidioma"];

                    par = cmd.CreateParameter();
                    cmd.Parameters.Add(par);
                    par.ParameterName = "@nomidioma";
                    par.Direction = ParameterDirection.Input;
                    par.DbType = DbType.String;
                    par.Size = 50;
                    if (string.IsNullOrEmpty((string)jo["nomidioma"]))
                        par.Value = DBNull.Value;
                    else
                        par.Value = (string)jo["nomidioma"];
                    
                    */
                    
                    //si estan corregidos los tags de vuce, referentes a idiomas, sacar el comentario de arriba
                    //y comentar este:
                    par = cmd.CreateParameter();
                    cmd.Parameters.Add(par);
                    par.ParameterName = "@codidioma";
                    par.Direction = ParameterDirection.Input;
                    par.DbType = DbType.Int32;
                    if (jo["nomidioma"] == null)
                        par.Value = DBNull.Value;
                    else
                        par.Value = jo["nomidioma"];

                    par = cmd.CreateParameter();
                    cmd.Parameters.Add(par);
                    par.ParameterName = "@nomidioma";
                    par.Direction = ParameterDirection.Input;
                    par.DbType = DbType.String;
                    par.Size = 50;
                    if (string.IsNullOrEmpty((string)jo["itemidioma"]))
                        par.Value = DBNull.Value;
                    else
                        par.Value = (string)jo["itemidioma"];
                    
                    DataSet ds = new DataSet();
                    DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
                    da.Fill(ds);

                    cadena = cadena + " " + ds.Tables[0].Rows[0]["nom_idioma"].ToString();

                }
            }

            
            par = null;
            cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitud_especificacion_insert";
            //DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // reinscripcion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@reinscripcion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Reinscripcion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Reinscripcion;
            // drano
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@drano";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Drano))
                par.Value = DBNull.Value;
            else
                par.Value = param.Drano;
            // drnro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@drnro";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Drnro))
                par.Value = DBNull.Value;
            else
                par.Value = param.Drnro;
            // suceano
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@suceano";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 4;
            if (string.IsNullOrEmpty(param.Suceano))
                par.Value = DBNull.Value;
            else
                par.Value = param.Suceano;
            // sucenro
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@sucenro";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Sucenro))
                par.Value = DBNull.Value;
            else
                par.Value = param.Sucenro;
            // certificado
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@certificado"; //nro de certificado asociado
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 15;
            if (string.IsNullOrEmpty(param.Certificado))
                par.Value = DBNull.Value;
            else
                par.Value = param.Certificado;
            // expediente
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@expediente";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(param.Expediente))
                par.Value = DBNull.Value;
            else
                par.Value = param.Expediente;

            // tcambempresa
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambempresa";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambempresa))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambempresa;
            // tcambrepresentante
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambrepresentante";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambrepresentante))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambrepresentante;
            // tcambalmacenamiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambalmacenamiento";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambalmacenamiento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambalmacenamiento;
            // tcambdenominacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambdenominacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambdenominacion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambdenominacion;
            // tcambenvase
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambenvase";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambenvase))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambenvase;
            // tcambformulacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambformulacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambformulacion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambformulacion;
            // tcambcancelacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@tcambcancelacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 1;
            if (string.IsNullOrEmpty(param.Tcambcancelacion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Tcambcancelacion;

            //IDIOMA
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idioma";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 20;
            if (string.IsNullOrEmpty(cadena))
                par.Value = DBNull.Value;
            else
                par.Value = cadena;
            

            cmd.ExecuteNonQuery();

        }




        public PkgEbxml.SolicitudAmpliadoInsertParam solicitudampliadoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.SolicitudAmpliadoInsertParam param = newSolicitudAmpliadoInsertParam(map);
            solicitudampliadoInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudAmpliadoInsertParam solicitudampliadoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.SolicitudAmpliadoInsertParam param = newSolicitudAmpliadoInsertParam(json);
            solicitudampliadoInsert(conn, param);
            return param;
        }

        public PkgEbxml.SolicitudAmpliadoInsertParam solicitudampliadoInsert(Connection conn)
        {
            PkgEbxml.SolicitudAmpliadoInsertParam param = newSolicitudAmpliadoInsertParam();
            solicitudampliadoInsert(conn, param);
            return param;
        }

        public void solicitudampliadoInsert(Connection conn, PkgEbxml.SolicitudAmpliadoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_solicitud_reinscripcion_insert";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // drano
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@drano";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 10;
            if (string.IsNullOrEmpty(param.Drano))
                par.Value = DBNull.Value;
            else
                par.Value = param.Drano;


            cmd.ExecuteNonQuery();

        }





        public PkgEbxml.LaboratorioCertificadoInsertParam laboratoriocertificadoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.LaboratorioCertificadoInsertParam param = newLaboratorioCertificadoInsertParam(map);
            laboratoriocertificadoInsert(conn, param);
            return param;
        }

        public PkgEbxml.LaboratorioCertificadoInsertParam laboratoriocertificadoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.LaboratorioCertificadoInsertParam param = newLaboratorioCertificadoInsertParam(json);
            laboratoriocertificadoInsert(conn, param);
            return param;
        }

        public PkgEbxml.LaboratorioCertificadoInsertParam laboratoriocertificadoInsert(Connection conn)
        {
            PkgEbxml.LaboratorioCertificadoInsertParam param = newLaboratorioCertificadoInsertParam();
            laboratoriocertificadoInsert(conn, param);
            return param;
        }

        public void laboratoriocertificadoInsert(Connection conn, PkgEbxml.LaboratorioCertificadoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].EBX_laboratorio_acreditado_insert";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;

            // item
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@laboratorioacreditadoitem";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Laboratorioacreditadoitem == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Laboratorioacreditadoitem;
            // tipo
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idlaboratorioacreditadotipo";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.IDLaboratorioAcreditadoTipo == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.IDLaboratorioAcreditadoTipo;
            // id
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@ididlaboratorioacreditado";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.IDIDLaboratorioAcreditado == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.IDIDLaboratorioAcreditado;
            // nombre
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nombre";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 300;
            if (string.IsNullOrEmpty(param.Nombre))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nombre;
            cmd.ExecuteNonQuery();

        }



        public PkgEbxml.AditivoInsertParam newAditivoInsertParam()
        {
            return new AditivoInsertParam();
        }

        public PkgEbxml.AditivoInsertParam newAditivoInsertParam(Dictionary<string, string> map)
        {
            return new AditivoInsertParam(map);
        }

        public PkgEbxml.AditivoInsertParam newAditivoInsertParam(JSONObject json)
        {
            return new AditivoInsertParam(json);
        }

        public PkgEbxml.AdjuntoInsertParam newAdjuntoInsertParam()
        {
            return new AdjuntoInsertParam();
        }

        public PkgEbxml.AdjuntoInsertParam newAdjuntoInsertParam(Dictionary<string, string> map)
        {
            return new AdjuntoInsertParam(map);
        }

        public PkgEbxml.AdjuntoInsertParam newAdjuntoInsertParam(JSONObject json)
        {
            return new AdjuntoInsertParam(json);
        }

        public PkgEbxml.AlmacenInsertParam newAlmacenInsertParam()
        {
            return new AlmacenInsertParam();
        }

        public PkgEbxml.AlmacenInsertParam newAlmacenInsertParam(Dictionary<string, string> map)
        {
            return new AlmacenInsertParam(map);
        }

        public PkgEbxml.AlmacenInsertParam newAlmacenInsertParam(JSONObject json)
        {
            return new AlmacenInsertParam(json);
        }

        public PkgEbxml.ComposicionInsertParam newComposicionInsertParam()
        {
            return new ComposicionInsertParam();
        }

        public PkgEbxml.ComposicionInsertParam newComposicionInsertParam(Dictionary<string, string> map)
        {
            return new ComposicionInsertParam(map);
        }

        public PkgEbxml.ComposicionInsertParam newComposicionInsertParam(JSONObject json)
        {
            return new ComposicionInsertParam(json);
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam()
        {
            return new EmpresaExtranjeraUpdateParam();
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam(Dictionary<string, string> map)
        {
            return new EmpresaExtranjeraUpdateParam(map);
        }

        public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam(JSONObject json)
        {
            return new EmpresaExtranjeraUpdateParam(json);
        }

        public PkgEbxml.EnvaseInsertParam newEnvaseInsertParam()
        {
            return new EnvaseInsertParam();
        }

        public PkgEbxml.EnvaseInsertParam newEnvaseInsertParam(Dictionary<string, string> map)
        {
            return new EnvaseInsertParam(map);
        }

        public PkgEbxml.EnvaseInsertParam newEnvaseInsertParam(JSONObject json)
        {
            return new EnvaseInsertParam(json);
        }

        public PkgEbxml.LaboratorioInsertParam newLaboratorioInsertParam()
        {
            return new LaboratorioInsertParam();
        }

        public PkgEbxml.LaboratorioInsertParam newLaboratorioInsertParam(Dictionary<string, string> map)
        {
            return new LaboratorioInsertParam(map);
        }

        public PkgEbxml.LaboratorioInsertParam newLaboratorioInsertParam(JSONObject json)
        {
            return new LaboratorioInsertParam(json);
        }

        public PkgEbxml.N8GetParam newN8GetParam()
        {
            return new N8GetParam();
        }

        public PkgEbxml.N8GetParam newN8GetParam(Dictionary<string, string> map)
        {
            return new N8GetParam(map);
        }

        public PkgEbxml.N8GetParam newN8GetParam(JSONObject json)
        {
            return new N8GetParam(json);
        }

        /* MODIFICADO POR CESAR BOCANEGRA */
        //DGS003

        public PkgEbxml.N8dgs003GetParam newN8dgs003GetParam()
        {
            return new N8dgs003GetParam();
        }

        public PkgEbxml.N8dgs003GetParam newN8dgs003GetParam(Dictionary<string, string> map)
        {
            return new N8dgs003GetParam(map);
        }

        public PkgEbxml.N8dgs003GetParam newN8dgs003GetParam(JSONObject json)
        {
            return new N8dgs003GetParam(json);
        }

        //DGS004
        public PkgEbxml.N8dgs004GetParam newN8dgs004GetParam()
        {
            return new N8dgs004GetParam();
        }

        public PkgEbxml.N8dgs004GetParam newN8dgs004GetParam(Dictionary<string, string> map)
        {
            return new N8dgs004GetParam(map);
        }

        public PkgEbxml.N8dgs004GetParam newN8dgs004GetParam(JSONObject json)
        {
            return new N8dgs004GetParam(json);
        }


        /* FIN DE LA MODIFICACION */

        /* MODIFICADO POR CESAR BOCANEGRA */

        public PkgEbxml.N8dgs002GetParam newN8dgs002GetParam()
        {
            return new N8dgs002GetParam();
        }

        public PkgEbxml.N8dgs002GetParam newN8dgs002GetParam(Dictionary<string, string> map)
        {
            return new N8dgs002GetParam(map);
        }

        public PkgEbxml.N8dgs002GetParam newN8dgs002GetParam(JSONObject json)
        {
            return new N8dgs002GetParam(json);
        }

        /* FIN DE LA MODIFICACION */

        public PkgEbxml.N8dgs009GetParam newN8dgs009GetParam()
        {
            return new N8dgs009GetParam();
        }

        public PkgEbxml.N8dgs009GetParam newN8dgs009GetParam(Dictionary<string, string> map)
        {
            return new N8dgs009GetParam(map);
        }

        public PkgEbxml.N8dgs009GetParam newN8dgs009GetParam(JSONObject json)
        {
            return new N8dgs009GetParam(json);
        }

         /*************************** */
        public PkgEbxml.N8dgs006GetParam newN8dgs006GetParam()
        {
            return new N8dgs006GetParam();
        }

        public PkgEbxml.N8dgs006GetParam newN8dgs006GetParam(Dictionary<string, string> map)
        {
            return new N8dgs006GetParam(map);
        }

        public PkgEbxml.N8dgs006GetParam newN8dgs006GetParam(JSONObject json)
        {
            return new N8dgs006GetParam(json);
        }

        public PkgEbxml.PersonaUpdateParam newPersonaUpdateParam()
        {
            return new PersonaUpdateParam();
        }

        public PkgEbxml.PersonaUpdateParam newPersonaUpdateParam(Dictionary<string, string> map)
        {
            return new PersonaUpdateParam(map);
        }

        public PkgEbxml.PersonaUpdateParam newPersonaUpdateParam(JSONObject json)
        {
            return new PersonaUpdateParam(json);
        }

        /* MODIFICADO POR CESAR BOCANEGRA */

        public PkgEbxml.TitularCertificadoParam newTitularCertificadoParam()
        {
            return new TitularCertificadoParam();
        }

        public PkgEbxml.TitularCertificadoParam newTitularCertificadoParam(Dictionary<string, string> map)
        {
            return new TitularCertificadoParam(map);
        }

        public PkgEbxml.TitularCertificadoParam newTitularCertificadoParam(JSONObject json)
        {
            return new TitularCertificadoParam(json);
        }

        /* FIN DE LA MODIFICACION */
        public PkgEbxml.ProductoInsertParam newProductoInsertParam()
        {
            return new ProductoInsertParam();
        }

        public PkgEbxml.ProductoInsertParam newProductoInsertParam(Dictionary<string, string> map)
        {
            return new ProductoInsertParam(map);
        }

        public PkgEbxml.ProductoInsertParam newProductoInsertParam(JSONObject json)
        {
            return new ProductoInsertParam(json);
        }

        public PkgEbxml.SolicitanteInsertParam newSolicitanteInsertParam()
        {
            return new SolicitanteInsertParam();
        }

        public PkgEbxml.SolicitanteInsertParam newSolicitanteInsertParam(Dictionary<string, string> map)
        {
            return new SolicitanteInsertParam(map);
        }

        public PkgEbxml.SolicitanteInsertParam newSolicitanteInsertParam(JSONObject json)
        {
            return new SolicitanteInsertParam(json);
        }



        public PkgEbxml.SolicitanteCambioInsertParam newSolicitanteCambioInsertParam()
        {
            return new SolicitanteCambioInsertParam();
        }

        public PkgEbxml.SolicitanteCambioInsertParam newSolicitanteCambioInsertParam(Dictionary<string, string> map)
        {
            return new SolicitanteCambioInsertParam(map);
        }

        public PkgEbxml.SolicitanteCambioInsertParam newSolicitanteCambioInsertParam(JSONObject json)
        {
            return new SolicitanteCambioInsertParam(json);
        }



        public PkgEbxml.SolicitudBorrarVersionParam newSolicitudBorrarVersionParam()
        {
            return new SolicitudBorrarVersionParam();
        }

        public PkgEbxml.SolicitudBorrarVersionParam newSolicitudBorrarVersionParam(Dictionary<string, string> map)
        {
            return new SolicitudBorrarVersionParam(map);
        }

        public PkgEbxml.SolicitudBorrarVersionParam newSolicitudBorrarVersionParam(JSONObject json)
        {
            return new SolicitudBorrarVersionParam(json);
        }

        public PkgEbxml.SolicitudCrearVersionParam newSolicitudCrearVersionParam()
        {
            return new SolicitudCrearVersionParam();
        }

        public PkgEbxml.SolicitudCrearVersionParam newSolicitudCrearVersionParam(Dictionary<string, string> map)
        {
            return new SolicitudCrearVersionParam(map);
        }

        public PkgEbxml.SolicitudCrearVersionParam newSolicitudCrearVersionParam(JSONObject json)
        {
            return new SolicitudCrearVersionParam(json);
        }

        public PkgEbxml.SolicitudInsertParam newSolicitudInsertParam()
        {
            return new SolicitudInsertParam();
        }

        public PkgEbxml.SolicitudInsertParam newSolicitudInsertParam(Dictionary<string, string> map)
        {
            return new SolicitudInsertParam(map);
        }

        public PkgEbxml.SolicitudInsertParam newSolicitudInsertParam(JSONObject json)
        {
            return new SolicitudInsertParam(json);
        }


        public PkgEbxml.SolicitudEspecificacionInsertParam newSolicitudEspecificacionInsertParam()
        {
            return new SolicitudEspecificacionInsertParam();
        }

        public PkgEbxml.SolicitudEspecificacionInsertParam newSolicitudEspecificacionInsertParam(Dictionary<string, string> map)
        {
            return new SolicitudEspecificacionInsertParam(map);
        }

        public PkgEbxml.SolicitudEspecificacionInsertParam newSolicitudEspecificacionInsertParam(JSONObject json)
        {
            return new SolicitudEspecificacionInsertParam(json);
        }


        public PkgEbxml.SolicitudAmpliadoInsertParam newSolicitudAmpliadoInsertParam()
        {
            return new SolicitudAmpliadoInsertParam();
        }

        public PkgEbxml.SolicitudAmpliadoInsertParam newSolicitudAmpliadoInsertParam(Dictionary<string, string> map)
        {
            return new SolicitudAmpliadoInsertParam(map);
        }

        public PkgEbxml.SolicitudAmpliadoInsertParam newSolicitudAmpliadoInsertParam(JSONObject json)
        {
            return new SolicitudAmpliadoInsertParam(json);
        }



        public PkgEbxml.LaboratorioCertificadoInsertParam newLaboratorioCertificadoInsertParam()
        {
            return new LaboratorioCertificadoInsertParam();
        }

        public PkgEbxml.LaboratorioCertificadoInsertParam newLaboratorioCertificadoInsertParam(Dictionary<string, string> map)
        {
            return new LaboratorioCertificadoInsertParam(map);
        }

        public PkgEbxml.LaboratorioCertificadoInsertParam newLaboratorioCertificadoInsertParam(JSONObject json)
        {
            return new LaboratorioCertificadoInsertParam(json);
        }


        public class AditivoInsertParam
        {

            private int? idaditivo;
            private int? idproducto;
            private string descaditivo;
            private string pesoaditivo;
            private string sincodex;
            private string sustgrasa;
            private int? itemaditivo;

            public AditivoInsertParam()
            {
            }

            public AditivoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public AditivoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idaditivo
            {
                get { return idaditivo; }
                set { this.idaditivo = value; }
            }

            public int? Idproducto
            {
                get { return idproducto; }
                set { this.idproducto = value; }
            }

            public string Descaditivo
            {
                get { return descaditivo; }
                set { this.descaditivo = value; }
            }

            public string Pesoaditivo
            {
                get { return pesoaditivo; }
                set { this.pesoaditivo = value; }
            }

            public string Sincodex
            {
                get { return sincodex; }
                set { this.sincodex = value; }
            }

            public string Sustgrasa
            {
                get { return sustgrasa; }
                set { this.sustgrasa = value; }
            }

            public int? Itemaditivo
            {
                get { return itemaditivo; }
                set { this.itemaditivo = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class AdjuntoInsertParam
        {

            private int? idadjunto;
            private int? idsolicitud;
            private int? idversion;
            private string fecarchivo;
            private string nombarchivo;
            private string nombarchivosistema;

            public AdjuntoInsertParam()
            {
            }

            public AdjuntoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public AdjuntoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idadjunto
            {
                get { return idadjunto; }
                set { this.idadjunto = value; }
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public string Fecarchivo
            {
                get { return fecarchivo; }
                set { this.fecarchivo = value; }
            }

            public string Nombarchivo
            {
                get { return nombarchivo; }
                set { this.nombarchivo = value; }
            }

            public string Nombarchivosistema
            {
                get { return nombarchivosistema; }
                set { this.nombarchivosistema = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class AlmacenInsertParam
        {

            private int? almidpersona;
            private string almnombpersona;
            private int? almidtipodocu;
            private string almnumedocumento;
            private string almdirepersona;
            private string almidubigeo;
            private string almtelffijo;
            private string almtelffax;
            private string almdireemail;
            private string almdirereferencia;
            private int? repidpersona;
            private string repnombpersona;
            private string repidtipodocu;
            private string repnumedocumento;
            private string repdirepersona;

            private int? idtipopersona;
            private string resolucionplanta;

            private string expedienteplanta;

            /* modificado por CESAR BOCANEGRA */

            private string estbldepartamento; //DGS003

            public string Estbldepartamento
            {
                get { return estbldepartamento; }
                set { estbldepartamento = value; }
            }
            private string estblprovincia; //DGS003

            public string Estblprovincia
            {
                get { return estblprovincia; }
                set { estblprovincia = value; }
            }
            private string estbldistrito; //DGS003

            public string Estbldistrito
            {
                get { return estbldistrito; }
                set { estbldistrito = value; }
            }

            public int? Idtipopersona
            {
                get { return idtipopersona; }
                set { idtipopersona = value; }
            }

            public string Resolucionplanta
            {
                get { return resolucionplanta; }
                set { resolucionplanta = value; }
            }

            public string Expedienteplanta
            {
                get { return expedienteplanta; }
                set { expedienteplanta = value; }
            }

            /* FIN DE LA MODIFICACION */

            public AlmacenInsertParam()
            {
            }

            public AlmacenInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public AlmacenInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Almidpersona
            {
                get { return almidpersona; }
                set { this.almidpersona = value; }
            }

            public string Almnombpersona
            {
                get { return almnombpersona; }
                set { this.almnombpersona = value; }
            }

            public int? Almidtipodocu
            {
                get { return almidtipodocu; }
                set { this.almidtipodocu = value; }
            }

            public string Almnumedocumento
            {
                get { return almnumedocumento; }
                set { this.almnumedocumento = value; }
            }

            public string Almdirepersona
            {
                get { return almdirepersona; }
                set { this.almdirepersona = value; }
            }

            public string Almidubigeo
            {
                get { return almidubigeo; }
                set { this.almidubigeo = value; }
            }

            public string Almtelffijo
            {
                get { return almtelffijo; }
                set { this.almtelffijo = value; }
            }

            public string Almtelffax
            {
                get { return almtelffax; }
                set { this.almtelffax = value; }
            }

            public string Almdireemail
            {
                get { return almdireemail; }
                set { this.almdireemail = value; }
            }

            public string Almdirereferencia
            {
                get { return almdirereferencia; }
                set { this.almdirereferencia = value; }
            }

            public int? Repidpersona
            {
                get { return repidpersona; }
                set { this.repidpersona = value; }
            }

            public string Repnombpersona
            {
                get { return repnombpersona; }
                set { this.repnombpersona = value; }
            }

            public string Repidtipodocu
            {
                get { return repidtipodocu; }
                set { this.repidtipodocu = value; }
            }

            public string Repnumedocumento
            {
                get { return repnumedocumento; }
                set { this.repnumedocumento = value; }
            }

            public string Repdirepersona
            {
                get { return repdirepersona; }
                set { this.repdirepersona = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class ComposicionInsertParam
        {

            private int? idcomposicion;
            private int? idproducto;
            private string desccomposicion;
            private string itemcomposicion;

            private string descorigcomposicion;
            private string descnuevcomposicion;

            public ComposicionInsertParam()
            {
            }

            public ComposicionInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public ComposicionInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idcomposicion
            {
                get { return idcomposicion; }
                set { this.idcomposicion = value; }
            }

            public int? Idproducto
            {
                get { return idproducto; }
                set { this.idproducto = value; }
            }

            public string Desccomposicion
            {
                get { return desccomposicion; }
                set { this.desccomposicion = value; }
            }

            public string Itemcomposicion
            {
                get { return itemcomposicion; }
                set { this.itemcomposicion = value; }
            }


            public string Descorigcomposicion
            {
                get { return descorigcomposicion; }
                set { this.descorigcomposicion = value; }
            }

            public string Descnuevcomposicion
            {
                get { return descnuevcomposicion; }
                set { this.descnuevcomposicion = value; }
            }


            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }


        //MODIF POR CESAR BOCANEGRA

        /*public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam()
        {
            return new EmpresaExtranjeraUpdateParam();
        }*/

        public PkgEbxml.EstablecimientoInsertParam newEstablecimientoInsertParam()
        {
            return new EstablecimientoInsertParam();
        }

      /*  public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam(Dictionary<string, string> map)
        {
            return new EmpresaExtranjeraUpdateParam(map);
        }*/

        public PkgEbxml.EstablecimientoInsertParam newEstablecimientoInsertParam(Dictionary<string, string> map)
        {
            return new EstablecimientoInsertParam(map);
        }

        /*public PkgEbxml.EmpresaExtranjeraUpdateParam newEmpresaExtranjeraUpdateParam(JSONObject json)
        {
            return new EmpresaExtranjeraUpdateParam(json);
        }*/

        public PkgEbxml.EstablecimientoInsertParam newEstablecimientoInsertParam(JSONObject json)
        {
            return new EstablecimientoInsertParam(json);
        }
       
        public PkgEbxml.EstablecimientoInsertParam EstablecimientoInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.EstablecimientoInsertParam param = newEstablecimientoInsertParam(map);
            EstablecimientoInsert(conn, param);
            return param;
        }

        public PkgEbxml.EstablecimientoInsertParam EstablecimientoInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.EstablecimientoInsertParam param = newEstablecimientoInsertParam(json);
            EstablecimientoInsert(conn, param);
            return param;
        }

        public PkgEbxml.EstablecimientoInsertParam EstablecimientoInsert(Connection conn)
        {
            PkgEbxml.EstablecimientoInsertParam param = newEstablecimientoInsertParam();
            EstablecimientoInsert(conn, param);
            return param;
        }

        public void EstablecimientoInsert(Connection conn, PkgEbxml.EstablecimientoInsertParam param)
        {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "EBX_ESTABLECIMIENTO_INSERT";
            DbParameter par = null;
            // codigo del establecimiento autogen
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idestablec";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.Codestablecimiento == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Codestablecimiento;

            // codigo del establecimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codVUCE";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 6;
            if (string.IsNullOrEmpty(param.Codvuceestable))
                par.Value = DBNull.Value;
            else
                par.Value = param.Codvuceestable;


            // nombre del establecimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomestablec";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nomestablecimiento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nomestablecimiento;

            // direccion del establecimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direcestabl";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direstablecimiento))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direstablecimiento;

            // Expediente establecimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@expestablec";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Expplanta))
                par.Value = DBNull.Value;
            else
                par.Value = param.Expplanta;

            // Nro Resolucion establecimiento
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@resolestablec";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Resolhabil))
                par.Value = DBNull.Value;
            else
                par.Value = param.Resolhabil;

            cmd.ExecuteNonQuery();
            /*if (DBNull.Value.Equals(cmd.Parameters["@repidpersona"].Value))
                param.Repidpersona = null;
            else
                param.Repidpersona = (int?)cmd.Parameters["@repidpersona"].Value;*/
            if (DBNull.Value.Equals(cmd.Parameters["@idestablec"].Value))
                param.Codestablecimiento = null;
            else
                param.Codestablecimiento=(int?)cmd.Parameters["@idestablec"].Value;

        }

        //Destino insert CESAR BOCANEGRA

        public PkgEbxml.DestinoProdInsertParam newDestinoProdInsertParam()
        { return new DestinoProdInsertParam(); }

        public PkgEbxml.DestinoProdInsertParam newDestinoProdInsertParam(Dictionary<string, string> map)
        { return new DestinoProdInsertParam(map); }

        public PkgEbxml.DestinoProdInsertParam newDestinoProdInsertParam(JSONObject json)
        { return new DestinoProdInsertParam(json); }

        public PkgEbxml.DestinoProdInsertParam DestinoProdInsert(Connection conn, Dictionary<string, string> map)
        {
            PkgEbxml.DestinoProdInsertParam param = newDestinoProdInsertParam(map);
            DestinoProdInsert(conn, param);
            return param;
        }

        public PkgEbxml.DestinoProdInsertParam DestinoProdInsert(Connection conn, JSONObject json)
        {
            PkgEbxml.DestinoProdInsertParam param = newDestinoProdInsertParam(json);
            DestinoProdInsert(conn, param);
            return param;
        }

        public PkgEbxml.DestinoProdInsertParam DestinoProdInsert(Connection conn)
        {
            PkgEbxml.DestinoProdInsertParam param = newDestinoProdInsertParam();
            DestinoProdInsert(conn, param);
            return param;
        }

        public void DestinoProdInsert(Connection conn, PkgEbxml.DestinoProdInsertParam param)
        {
            //codigo de insercion de destino
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "EBX_destino_prod";
            DbParameter par = null;

            // codigo identity de solicitud_destino que ira en la tabla solicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@soldesti";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.Soldesti == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Soldesti;

            // puerto de envio               
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@penvio";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Penvio))
                par.Value = DBNull.Value;
            else
                par.Value = param.Penvio;

            // puerto de destino
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@pdestino";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Pdestino))
                par.Value = DBNull.Value;
            else
                par.Value = param.Pdestino;

            // medio de transporte
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@mediotrans";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size=80;
            if (string.IsNullOrEmpty(param.Mediotransporte))
                par.Value = DBNull.Value;
            else
                par.Value = param.Mediotransporte;

            // fecha de embarque
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fechembarque";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            if (param.Fchembarque == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fchembarque;
            
            // codigo del expedidor
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codexpe";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.OUTcod_exped1 == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.OUTcod_exped1;

            // nombre del expedidor
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomexpe";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nom_exped))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nom_exped;

            // direccion del expedidor
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direexpe";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Expdireccion))
                par.Value = DBNull.Value;
            else
                par.Value = param.Expdireccion;

            // codigo del destinatario
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@coddesti";
            par.Direction = ParameterDirection.Output;
            par.DbType = DbType.Int32;
            if (param.OUTcod_desti1 == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.OUTcod_desti1;

            // nombre del destinatario
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nomdesti";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Nomdestinatario))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nomdestinatario;

            // direccion del destinatario
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@direcdesti";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Direc_destino))
                par.Value = DBNull.Value;
            else
                par.Value = param.Direc_destino;

            // notificaciones adicionales
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@notifad";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 250;
            if (string.IsNullOrEmpty(param.Notif_adicional))
                par.Value = DBNull.Value;
            else
                par.Value = param.Notif_adicional;

            //@codpais
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@codpais";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Codpaisdest == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Codpaisdest;

            //@nompais
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@nompais";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 50;
            if (string.IsNullOrEmpty(param.Nompaisdest))
                par.Value = DBNull.Value;
            else
                par.Value = param.Nompaisdest;



            cmd.ExecuteNonQuery();
            /*if (DBNull.Value.Equals(cmd.Parameters["@idestablec"].Value))
                param.Codestablecimiento = null;
            else
                param.Codestablecimiento=(int?)cmd.Parameters["@idestablec"].Value;*/

            //recuperando id de la tabla
            if (DBNull.Value.Equals(cmd.Parameters["@soldesti"].Value))
                param.Soldesti=null;
            else
                param.Soldesti=(int?)cmd.Parameters["@soldesti"].Value;

            //recuperando id del expedidor
            if (DBNull.Value.Equals(cmd.Parameters["@codexpe"].Value))
                param.OUTcod_exped1=null;
            else
                param.OUTcod_exped1=(int?)cmd.Parameters["@codexpe"].Value;

            //recuperando id del destinatario
            if (DBNull.Value.Equals(cmd.Parameters["@coddesti"].Value))
                param.OUTcod_desti1 = null;
            else
                param.OUTcod_desti1 = (int?)cmd.Parameters["@coddesti"].Value;


        }

        //AGREGADO POR CESAR BOCANEGRA

        public class DestinoProdInsertParam
        {
            private int? soldesti; //solicitud destino generado por el procedure           

            private string penvio; //puerto de envio
 
            private string pdestino; //puerto de destino
            
            private string mediotransporte; //medio de transporte
            
            private DateTime? fchembarque; //fecha de embarque

            private int? OUTcod_exped; // codigo del expedidor generado por el procedure
            
            private string nom_exped; //nombre del expedidor

            private string expdireccion; //direccion del expedidor

            private int? OUTcod_desti; //codigo del destinatario generado por el procedure            
           
            private string nomdestinatario; //nombre del destinatario
            
            private string direc_destino; //direccion del destinatario

            private string notif_adicional; //notificacion adicional

            private int? codpaisdest; //codigo del pais DGS004

            private string nompaisdest; //nombre del pais DGS004
 
            //constructor
            public DestinoProdInsertParam() { }

            public DestinoProdInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public DestinoProdInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? OUTcod_desti1
            {
                get { return OUTcod_desti; }
                set { OUTcod_desti = value; }
            }

            public int? OUTcod_exped1
            {
                get { return OUTcod_exped; }
                set { OUTcod_exped = value; }
            }

            public int? Soldesti
            {
                get { return soldesti; }
                set { soldesti = value; }
            }

            public string Notif_adicional
            {
                get { return notif_adicional; }
                set { notif_adicional = value; }
            }

            public string Direc_destino
            {
                get { return direc_destino; }
                set { direc_destino = value; }
            }

            public string Nomdestinatario
            {
                get { return nomdestinatario; }
                set { nomdestinatario = value; }
            }

            public string Expdireccion
            {
                get { return expdireccion; }
                set { expdireccion = value; }
            }         

            public string Nom_exped
            {
                get { return nom_exped; }
                set { nom_exped = value; }
            }

            public DateTime? Fchembarque
            {
                get { return fchembarque; }
                set { fchembarque = value; }
            }

            public string Mediotransporte
            {
                get { return mediotransporte; }
                set { mediotransporte = value; }
            }

            public string Pdestino
            {
                get { return pdestino; }
                set { pdestino = value; }
            }

            public string Penvio
            {
                get { return penvio; }
                set { penvio = value; }
            }

            public int? Codpaisdest
            {
                get { return codpaisdest; }
                set { codpaisdest = value; }
            }

            public string Nompaisdest
            {
                get { return nompaisdest; }
                set { nompaisdest = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        //FIN DE LA COLABORACION

        public class EstablecimientoInsertParam 
        {
            private string expplanta;            
            private string resolhabil;
            private string nomestablecimiento;
            private string direstablecimiento;
            private int? codestablecimiento;
            private string codvuceestable;


            //constructor
            public EstablecimientoInsertParam()
            { }

            public EstablecimientoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public EstablecimientoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public string Expplanta
            {
                get { return expplanta; }
                set { expplanta = value; }
            }

            public string Resolhabil
            {
                get { return resolhabil; }
                set { resolhabil = value; }
            }

            public string Nomestablecimiento
            {
                get { return nomestablecimiento; }
                set { nomestablecimiento = value; }
            }

            public string Direstablecimiento
            {
                get { return direstablecimiento; }
                set { direstablecimiento = value; }
            }

            public int? Codestablecimiento
            {
                get { return codestablecimiento; }
                set { codestablecimiento = value; }
            }

            public string Codvuceestable
            {
                get { return codvuceestable; }
                set { codvuceestable = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        //FIN DE LA MODIFICACION
        
        /* MODIFICADO POR CESAR BOCANEGRA */

        public class TitularCertificadoParam
        {
            private string nomtitucertificado;//Nombre o Razon Socil            
            private string numecertif;//Nro del certificado            
            private string procpaisorigen;//Codigo del pais de origen               
            private string paisorigen;//Nombre del pais de origen            
            private int? idsolicitud;            
            private int? idversion;
            private JSONArray jsonproductos;
            private int? repidpersona;
            private DateTime? emisioncertif;
            private DateTime? fincertif;
            

            public DateTime? Fincertif
            {
                get { return fincertif; }
                set { fincertif = value; }
            }

            public DateTime? Emisioncertif
            {
                get { return emisioncertif; }
                set { emisioncertif = value; }
            }
            
            public int? Repidpersona
            {
                get { return repidpersona; }
                set { repidpersona = value; }
            }
            private int? idpersona;

            public int? Idpersona
            {
                get { return idpersona; }
                set { idpersona = value; }
            }
 
            public TitularCertificadoParam() { }

            public TitularCertificadoParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public TitularCertificadoParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public string Nomtitucertificado
            {
                get { return nomtitucertificado; }
                set { nomtitucertificado = value; }
            }

            public string Numecertif
            {
                get { return numecertif; }
                set { numecertif = value; }
            }

            public string Procpaisorigen
            {
                get { return procpaisorigen; }
                set { procpaisorigen = value; }
            }

            public string Paisorigen
            {
                get { return paisorigen; }
                set { paisorigen = value; }
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { idversion = value; }
            }

            public JSONArray Jsonproductos
            {
                get { return jsonproductos; }
                set { jsonproductos = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        /* FIN DE LA MODIFICACION */


        public class EmpresaExtranjeraUpdateParam
        {

            private string nombpersona;
            private string direpersona;
            private int? idpais;
            private string nombpais;
            private string nombautoridad;
            private int? idtipodocu;
            private string numedocumento;
            private string ubigeo;
            private string telffijo;
            private string telffax;
            private string direemail;
            private string direreferencia;
            private string repnombpersona;
            private string repidtipodocu;
            private string repnumedocumento;
            private int? idtipopersona;
            private string qaresp;
            private int? repidpersona;
            private int? idpersona;
            
            public EmpresaExtranjeraUpdateParam()
            {
            }

            public EmpresaExtranjeraUpdateParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public EmpresaExtranjeraUpdateParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public string Nombpersona
            {
                get { return nombpersona; }
                set { this.nombpersona = value; }
            }

            public string Direpersona
            {
                get { return direpersona; }
                set { this.direpersona = value; }
            }

            public int? Idpais
            {
                get { return idpais; }
                set { this.idpais = value; }
            }

            public string Nombpais
            {
                get { return nombpais; }
                set { this.nombpais = value; }
            }

            public string Nombautoridad
            {
                get { return nombautoridad; }
                set { this.nombautoridad = value; }
            }

            public int? Idtipodocu
            {
                get { return idtipodocu; }
                set { this.idtipodocu = value; }
            }

            public string Numedocumento
            {
                get { return numedocumento; }
                set { this.numedocumento = value; }
            }

            public string Ubigeo
            {
                get { return ubigeo; }
                set { this.ubigeo = value; }
            }

            public string Telffijo
            {
                get { return telffijo; }
                set { this.telffijo = value; }
            }

            public string Telffax
            {
                get { return telffax; }
                set { this.telffax = value; }
            }

            public string Direemail
            {
                get { return direemail; }
                set { this.direemail = value; }
            }

            public string Direreferencia
            {
                get { return direreferencia; }
                set { this.direreferencia = value; }
            }

            public string Repnombpersona
            {
                get { return repnombpersona; }
                set { this.repnombpersona = value; }
            }

            public string Repidtipodocu
            {
                get { return repidtipodocu; }
                set { this.repidtipodocu = value; }
            }

            public string Repnumedocumento
            {
                get { return repnumedocumento; }
                set { this.repnumedocumento = value; }
            }

            public int? Idtipopersona
            {
                get { return idtipopersona; }
                set { this.idtipopersona = value; }
            }

            public string Qaresp
            {
                get { return qaresp; }
                set { this.qaresp = value; }
            }

            public int? Repidpersona
            {
                get { return repidpersona; }
                set { this.repidpersona = value; }
            }

            public int? Idpersona
            {
                get { return idpersona; }
                set { this.idpersona = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class EnvaseInsertParam
        {

            private int? idenvase;
            private int? idproducto;
            private string tipoenvase;
            private string mateenvase;
            private string capaenvase;
            private int? itemenvase;

            public EnvaseInsertParam()
            {
            }

            public EnvaseInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public EnvaseInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idenvase
            {
                get { return idenvase; }
                set { this.idenvase = value; }
            }

            public int? Idproducto
            {
                get { return idproducto; }
                set { this.idproducto = value; }
            }

            public string Tipoenvase
            {
                get { return tipoenvase; }
                set { this.tipoenvase = value; }
            }

            public string Mateenvase
            {
                get { return mateenvase; }
                set { this.mateenvase = value; }
            }

            public string Capaenvase
            {
                get { return capaenvase; }
                set { this.capaenvase = value; }
            }

            public int? Itemenvase
            {
                get { return itemenvase; }
                set { this.itemenvase = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class LaboratorioInsertParam
        {

            private int? perlabidpersona;
            private string perlabtelffijo;
            private string perlabtelffax;
            private string perlabtelfcelular;
            private string perlabnumedocumento;
            private string perlabnombpersona;
            private string perlabidubigeo;
            private int? perlabidtipopersona;
            private int? perlabidtipodocu;
            private string perlabdirepersona;
            private string perlabdireemail;
            private int? labidpersona;
            private string labnumedocumento;
            private string labnombpersona;
            private string labidubigeo;
            private int? labidtipodocu;
            private string labdirepersona;

            public LaboratorioInsertParam()
            {
            }

            public LaboratorioInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public LaboratorioInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Perlabidpersona
            {
                get { return perlabidpersona; }
                set { this.perlabidpersona = value; }
            }

            public string Perlabtelffijo
            {
                get { return perlabtelffijo; }
                set { this.perlabtelffijo = value; }
            }

            public string Perlabtelffax
            {
                get { return perlabtelffax; }
                set { this.perlabtelffax = value; }
            }

            public string Perlabtelfcelular
            {
                get { return perlabtelfcelular; }
                set { this.perlabtelfcelular = value; }
            }

            public string Perlabnumedocumento
            {
                get { return perlabnumedocumento; }
                set { this.perlabnumedocumento = value; }
            }

            public string Perlabnombpersona
            {
                get { return perlabnombpersona; }
                set { this.perlabnombpersona = value; }
            }

            public string Perlabidubigeo
            {
                get { return perlabidubigeo; }
                set { this.perlabidubigeo = value; }
            }

            public int? Perlabidtipopersona
            {
                get { return perlabidtipopersona; }
                set { this.perlabidtipopersona = value; }
            }

            public int? Perlabidtipodocu
            {
                get { return perlabidtipodocu; }
                set { this.perlabidtipodocu = value; }
            }

            public string Perlabdirepersona
            {
                get { return perlabdirepersona; }
                set { this.perlabdirepersona = value; }
            }

            public string Perlabdireemail
            {
                get { return perlabdireemail; }
                set { this.perlabdireemail = value; }
            }

            public int? Labidpersona
            {
                get { return labidpersona; }
                set { this.labidpersona = value; }
            }

            public string Labnumedocumento
            {
                get { return labnumedocumento; }
                set { this.labnumedocumento = value; }
            }

            public string Labnombpersona
            {
                get { return labnombpersona; }
                set { this.labnombpersona = value; }
            }

            public string Labidubigeo
            {
                get { return labidubigeo; }
                set { this.labidubigeo = value; }
            }

            public int? Labidtipodocu
            {
                get { return labidtipodocu; }
                set { this.labidtipodocu = value; }
            }

            public string Labdirepersona
            {
                get { return labdirepersona; }
                set { this.labdirepersona = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class N8GetParam
        {

            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curPetitioner;
            private DbDataReader curSpecific;
            private DbDataReader curFactory;
            private DbDataReader curStorage;
            private DbDataReader curProducts;
            private DbDataReader curlaboratory;

            public N8GetParam()
            {
            }

            public N8GetParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurPetitioner
            {
                get { return curPetitioner; }
                set { this.curPetitioner = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { this.curSpecific = value; }
            }

            public DbDataReader CurFactory
            {
                get { return curFactory; }
                set { this.curFactory = value; }
            }

            public DbDataReader CurStorage
            {
                get { return curStorage; }
                set { this.curStorage = value; }
            }

            public DbDataReader CurProducts
            {
                get { return curProducts; }
                set { this.curProducts = value; }
            }

            public DbDataReader CurLaboratory
            {
                get { return curlaboratory; }
                set { curlaboratory = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        /* MODIFICADO POR CESAR BOCANEGRA */

        public class N8dgs004GetParam
        {
            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curSpecific;
            private DbDataReader curPetitioner;
            private DbDataReader curSanitaryRegisterH;
            private DbDataReader curProductDest;
            private DbDataReader curSanitaryRegister;

            public N8dgs004GetParam() { }

            public N8dgs004GetParam(Dictionary<string, string> map) 
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8dgs004GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { curSpecific = value; }
            }

            public DbDataReader CurPetitioner
            {
                get { return curPetitioner; }
                set { curPetitioner = value; }
            }

            public DbDataReader CurSanitaryRegisterH
            {
                get { return curSanitaryRegisterH; }
                set { curSanitaryRegisterH = value; }
            }

            public DbDataReader CurProductDest
            {
                get { return curProductDest; }
                set { curProductDest = value; }
            }

            public DbDataReader CurSanitaryRegister
            {
                get { return curSanitaryRegister; }
                set { curSanitaryRegister = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }
        }

        public class N8dgs003GetParam
        {
            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curSpecific;          
            private DbDataReader curPetitioner;         
            private DbDataReader curStorageLocation;          
            private DbDataReader curSanitaryRegisterEs;
            private DbDataReader curSanitaryRegisterPd; 
            //private DbDataReader curAdjuntos;

            public N8dgs003GetParam() { }

            public N8dgs003GetParam(Dictionary<string, string> map) 
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8dgs003GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { curSpecific = value; }
            }

            public DbDataReader CurPetitioner
            {
                get { return curPetitioner; }
                set { curPetitioner = value; }
            }

            public DbDataReader CurStorageLocation
            {
                get { return curStorageLocation; }
                set { curStorageLocation = value; }
            }

            public DbDataReader CurSanitaryRegisterEs
            {
                get { return curSanitaryRegisterEs; }
                set { curSanitaryRegisterEs = value; }
            }

            public DbDataReader CurSanitaryRegisterPd
            {
                get { return curSanitaryRegisterPd; }
                set { curSanitaryRegisterPd = value; }
            }
/*
            public DbDataReader CurAdjuntos
            {
                get { return curAdjuntos; }
                set { curAdjuntos = value; }
            }
            */
            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }
        }

        /* FIN DE LA MODIFICACION */ 

        public class N8dgs002GetParam
        {
            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curSpecific;
            private DbDataReader curEstablishment;
            private DbDataReader curProductDestination;
            private DbDataReader curFoodDrink;

            //constructor
            public N8dgs002GetParam() { }

            public N8dgs002GetParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8dgs002GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { curSpecific = value; }
            }

            public DbDataReader CurEstablishment
            {
                get { return curEstablishment; }
                set { curEstablishment = value; }
            }

            public DbDataReader CurProductDestination
            {
                get { return curProductDestination; }
                set { curProductDestination = value; }
            }

            public DbDataReader CurFoodDrink
            {
                get { return curFoodDrink; }
                set { curFoodDrink = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }
        }

        /* AGREGADO POR CESAR BOCANEGRA */

        public class N8dgs009GetParam
        {
            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curPetitioner;
            private DbDataReader curSpecific;
            private DbDataReader curStorage;

            
            private DbDataReader curFactory;
            private DbDataReader curProducts;

            public N8dgs009GetParam() { }

            public N8dgs009GetParam(Dictionary<string, string> map) 
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8dgs009GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurPetitioner
            {
                get { return curPetitioner; }
                set { this.curPetitioner = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { this.curSpecific = value; }
            }

            public DbDataReader CurFactory
            {
                get { return curFactory; }
                set { this.curFactory = value; }
            }

            public DbDataReader CurProducts
            {
                get { return curProducts; }
                set { this.curProducts = value; }
            }

            public DbDataReader CurStorage
            {
                get { return curStorage; }
                set { curStorage = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }


        /* FIN DE LA MODIFICACION */


        public class N8dgs006GetParam
        {

            private int? iddr;
            private string estado;
            private string xmlns;
            private string xsd;
            private DbDataReader curPetitioner;
            private DbDataReader curSpecific;
            private DbDataReader curFactory;
            private DbDataReader curProducts;

            public N8dgs006GetParam()
            {
            }

            public N8dgs006GetParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public N8dgs006GetParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Iddr
            {
                get { return iddr; }
                set { this.iddr = value; }
            }

            public string Estado
            {
                get { return estado; }
                set { this.estado = value; }
            }

            public string Xmlns
            {
                get { return xmlns; }
                set { this.xmlns = value; }
            }

            public string Xsd
            {
                get { return xsd; }
                set { this.xsd = value; }
            }

            public DbDataReader CurPetitioner
            {
                get { return curPetitioner; }
                set { this.curPetitioner = value; }
            }

            public DbDataReader CurSpecific
            {
                get { return curSpecific; }
                set { this.curSpecific = value; }
            }

            public DbDataReader CurFactory
            {
                get { return curFactory; }
                set { this.curFactory = value; }
            }

            public DbDataReader CurProducts
            {
                get { return curProducts; }
                set { this.curProducts = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class PersonaUpdateParam
        {

            private int? idpersona;
            private string nombpersona;
            private int? idtipodocu;
            private string numedocumento;
            private string direpersona;
            private string direreferencia;
            private string idubigeo;
            private string telffijo;
            private string telfcelular;
            private string telffax;
            private string direemail;
            private int? idtipopersona;

            public PersonaUpdateParam()
            {
            }

            public PersonaUpdateParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public PersonaUpdateParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idpersona
            {
                get { return idpersona; }
                set { this.idpersona = value; }
            }

            public string Nombpersona
            {
                get { return nombpersona; }
                set { this.nombpersona = value; }
            }

            public int? Idtipodocu
            {
                get { return idtipodocu; }
                set { this.idtipodocu = value; }
            }

            public string Numedocumento
            {
                get { return numedocumento; }
                set { this.numedocumento = value; }
            }

            public string Direpersona
            {
                get { return direpersona; }
                set { this.direpersona = value; }
            }

            public string Direreferencia
            {
                get { return direreferencia; }
                set { this.direreferencia = value; }
            }

            public string Idubigeo
            {
                get { return idubigeo; }
                set { this.idubigeo = value; }
            }

            public string Telffijo
            {
                get { return telffijo; }
                set { this.telffijo = value; }
            }

            public string Telfcelular
            {
                get { return telfcelular; }
                set { this.telfcelular = value; }
            }

            public string Telffax
            {
                get { return telffax; }
                set { this.telffax = value; }
            }

            public string Direemail
            {
                get { return direemail; }
                set { this.direemail = value; }
            }

            public int? Idtipopersona
            {
                get { return idtipopersona; }
                set { this.idtipopersona = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class ProductoInsertParam
        {

            private int? idproducto;
            private int? idsolicitud;
            private int? idversion;
            private int? numeitem;
            private string idsubpartida;
            private string nombproducto;

            private string denominacioncomercial;

            private string marcproducto;
            private string condconsalma;
            private string perivida;
            private string sistlote;
            private string codipartida;
            private string contaditivo;
            private string codiclase;
            private string nombclase;
            private string codigrupo;
            private string autosanitaria;

            private string registrosanitario;
            private string estadoregistro;
            private string cancelaregistro;

            //modificado por CESAR BOCANEGRA
            
            private string descrip_producto;
            private string nom_producto;
            private string embalaje_producto;
            private string cant_embalada;
            private string pres_producto;            
            private string pneto_producto;
            private string pbruto_producto;
            private string temp_alma_producto;
            private DateTime? fech_vence_producto;
            private string nro_contenedor;
            private string factura_comercial;
            private string nom_embarque;            
            //private string nrolote;
            //private DateTime? fech_produccion;
            private JSONArray detalle;

            private DateTime? emisioncertif;
            private DateTime? fincertif;
            private string numecertif;
           
            private string nomfabricante;
           
            private double measureunit;
            
            private double pquantity;

            public DateTime? Fincertif
            {
                get { return fincertif; }
                set { fincertif = value; }
            }

            public DateTime? Emisioncertif
            {
                get { return emisioncertif; }
                set { emisioncertif = value; }
            }

            public string Numecertif
            {
                get { return numecertif; }
                set { numecertif = value; }
            }

            public string Nomfabricante
            {
                get { return nomfabricante; }
                set { nomfabricante = value; }
            }

            public double Measureunit
            {
                get { return measureunit; }
                set { measureunit = value; }
            }

            public double Pquantity
            {
                get { return pquantity; }
                set { pquantity = value; }
            }
                       
            //fin de la modificacion

            public string Nom_producto
            {
                get { return nom_producto; }
                set { nom_producto = value; }
            }

            public string Descrip_producto
            {
                get { return descrip_producto; }
                set { descrip_producto = value; }
            }

            public string Embalaje_producto
            {
                get { return embalaje_producto; }
                set { embalaje_producto = value; }
            }

            public string Cant_embalada
            {
                get { return cant_embalada; }
                set { cant_embalada = value; }
            }

            public string Pres_producto
            {
                get { return pres_producto; }
                set { pres_producto = value; }
            }

            public string Pneto_producto
            {
                get { return pneto_producto; }
                set { pneto_producto = value; }
            }

            public string Pbruto_producto
            {
                get { return pbruto_producto; }
                set { pbruto_producto = value; }
            }

            public string Temp_alma_producto
            {
                get { return temp_alma_producto; }
                set { temp_alma_producto = value; }
            }

            public DateTime? Fech_vence_producto
            {
                get { return fech_vence_producto; }
                set { fech_vence_producto = value; }
            }

            public string Nro_contenedor
            {
                get { return nro_contenedor; }
                set { nro_contenedor = value; }
            }

/*            public DateTime? Fech_produccion
            {
                get { return fech_produccion; }
                set { fech_produccion = value; }
            }

*/
            public string Factura_comercial
            {
                get { return factura_comercial; }
                set { factura_comercial = value; }
            }

            public string Nom_embarque
            {
                get { return nom_embarque; }
                set { nom_embarque = value; }
            }

 /*           public string Nrolote
            {
                get { return nrolote; }
                set { nrolote = value; }
            }*/

            public JSONArray Detalle
            {
                get { return detalle; }
                set { detalle = value; }
            }

            public string Registrosanitario
            {
                get { return registrosanitario; }
                set { registrosanitario = value; }
            }

            public string Estadoregistro
            {
                get { return estadoregistro; }
                set { estadoregistro = value; }
            }

            public string Cancelaregistro
            {
                get { return cancelaregistro; }
                set { cancelaregistro = value; }
            }

            public ProductoInsertParam()
            {
            }

            public ProductoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public ProductoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idproducto
            {
                get { return idproducto; }
                set { this.idproducto = value; }
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public int? Numeitem
            {
                get { return numeitem; }
                set { this.numeitem = value; }
            }

            public string Idsubpartida
            {
                get { return idsubpartida; }
                set { this.idsubpartida = value; }
            }

            public string Nombproducto
            {
                get { return nombproducto; }
                set { this.nombproducto = value; }
            }

            public string Denominacioncomercial
            {
                get { return denominacioncomercial; }
                set { denominacioncomercial = value; }
            }

            public string Marcproducto
            {
                get { return marcproducto; }
                set { this.marcproducto = value; }
            }

            public string Condconsalma
            {
                get { return condconsalma; }
                set { this.condconsalma = value; }
            }

            public string Perivida
            {
                get { return perivida; }
                set { this.perivida = value; }
            }

            public string Sistlote
            {
                get { return sistlote; }
                set { this.sistlote = value; }
            }

            public string Codipartida
            {
                get { return codipartida; }
                set { this.codipartida = value; }
            }

            public string Contaditivo
            {
                get { return contaditivo; }
                set { this.contaditivo = value; }
            }

            public string Codiclase
            {
                get { return codiclase; }
                set { this.codiclase = value; }
            }

            public string Nombclase
            {
                get { return nombclase; }
                set { this.nombclase = value; }
            }

            public string Codigrupo
            {
                get { return codigrupo; }
                set { this.codigrupo = value; }
            }

            public string Autosanitaria
            {
                get { return autosanitaria; }
                set { this.autosanitaria = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class SolicitanteInsertParam
        {

            private int? solidpersona;
            private string solnombpersona;
            private int? solidtipodocu;
            private string solnumedocumento;
            private string soldirepersona;
            private string solidubigeo;
            private string soltelffijo;
            private string soltelffax;
            private string soldireemail;
            private string soltelfcelular;
            private int? solidtipopersona;
            private string soldirereferencia;
            private int? repidpersona;
            private string repnombpersona;
            private string repidtipodocu;
            private string repnumedocumento;
            private string repdirepersona;






            public SolicitanteInsertParam()
            {
            }

            public SolicitanteInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitanteInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Solidpersona
            {
                get { return solidpersona; }
                set { this.solidpersona = value; }
            }

            public string Solnombpersona
            {
                get { return solnombpersona; }
                set { this.solnombpersona = value; }
            }

            public int? Solidtipodocu
            {
                get { return solidtipodocu; }
                set { this.solidtipodocu = value; }
            }

            public string Solnumedocumento
            {
                get { return solnumedocumento; }
                set { this.solnumedocumento = value; }
            }

            public string Soldirepersona
            {
                get { return soldirepersona; }
                set { this.soldirepersona = value; }
            }

            public string Solidubigeo
            {
                get { return solidubigeo; }
                set { this.solidubigeo = value; }
            }

            public string Soltelffijo
            {
                get { return soltelffijo; }
                set { this.soltelffijo = value; }
            }

            public string Soltelffax
            {
                get { return soltelffax; }
                set { this.soltelffax = value; }
            }

            public string Soldireemail
            {
                get { return soldireemail; }
                set { this.soldireemail = value; }
            }

            public string Soltelfcelular
            {
                get { return soltelfcelular; }
                set { this.soltelfcelular = value; }
            }

            public int? Solidtipopersona
            {
                get { return solidtipopersona; }
                set { this.solidtipopersona = value; }
            }

            public string Soldirereferencia
            {
                get { return soldirereferencia; }
                set { this.soldirereferencia = value; }
            }

            public int? Repidpersona
            {
                get { return repidpersona; }
                set { this.repidpersona = value; }
            }

            public string Repnombpersona
            {
                get { return repnombpersona; }
                set { this.repnombpersona = value; }
            }

            public string Repidtipodocu
            {
                get { return repidtipodocu; }
                set { this.repidtipodocu = value; }
            }

            public string Repnumedocumento
            {
                get { return repnumedocumento; }
                set { this.repnumedocumento = value; }
            }

            public string Repdirepersona
            {
                get { return repdirepersona; }
                set { this.repdirepersona = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }



        public class SolicitanteCambioInsertParam
        {

            private int? cambidpersona;
            private string cambempresa;
            private string cambdireccion;
            private string cambtelefono;
            private string cambfax;
            private int? cambidpersonarepre;
            private string cambtdocumentorepre;
            private string cambndocumentorepre;
            private string cambnombrerepre;
            private string cambdireccionrepre;


            public int? Cambidpersona
            {
                get { return cambidpersona; }
                set { cambidpersona = value; }
            }

            public string Cambempresa
            {
                get { return cambempresa; }
                set { cambempresa = value; }
            }

            public string Cambdireccion
            {
                get { return cambdireccion; }
                set { cambdireccion = value; }
            }

            public string Cambtelefono
            {
                get { return cambtelefono; }
                set { cambtelefono = value; }
            }

            public string Cambfax
            {
                get { return cambfax; }
                set { cambfax = value; }
            }


            public int? Cambidpersonarepre
            {
                get { return cambidpersonarepre; }
                set { cambidpersonarepre = value; }
            }

            public string Cambtdocumentorepre
            {
                get { return cambtdocumentorepre; }
                set { cambtdocumentorepre = value; }
            }

            public string Cambndocumentorepre
            {
                get { return cambndocumentorepre; }
                set { cambndocumentorepre = value; }
            }

            public string Cambnombrerepre
            {
                get { return cambnombrerepre; }
                set { cambnombrerepre = value; }
            }

            public string Cambdireccionrepre
            {
                get { return cambdireccionrepre; }
                set { cambdireccionrepre = value; }
            }

            public SolicitanteCambioInsertParam()
            {
            }

            public SolicitanteCambioInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitanteCambioInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }



            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }



        public class SolicitudBorrarVersionParam
        {

            private int? idsolicitud;
            private int? idversion;

            public SolicitudBorrarVersionParam()
            {
            }

            public SolicitudBorrarVersionParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitudBorrarVersionParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class SolicitudCrearVersionParam
        {

            private int? idsolicitud;
            private int? idversion;
            private string tipodoc;
            private string numedoc;
            private DateTime? fechrecepcion;

            public SolicitudCrearVersionParam()
            {
            }

            public SolicitudCrearVersionParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitudCrearVersionParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public string Tipodoc
            {
                get { return tipodoc; }
                set { this.tipodoc = value; }
            }

            public string Numedoc
            {
                get { return numedoc; }
                set { this.numedoc = value; }
            }

            public DateTime? Fechrecepcion
            {
                get { return fechrecepcion; }
                set { this.fechrecepcion = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class SolicitudInsertParam
        {

            private int? idsolicitud;
            private int? idversion;
            private string codiformato;
            private string tipodoc;
            private string numedoc;
            private int? idperssoli;
            private int? idpersrepr;
            private int? idemprext;
            private int? idpersalma;
            private int? idpersrepralma;
            private DateTime? fechrecepcion;
            private int? idperslab;
            private int? idpersperlab;
            //modificado por CESAR BOCANEGRA, se adicionan 3 parametros mas por la modificacion del procedure
            //EBX_solicitud_insert
            private int? id_expedidor;
            private int? id_destina;
            private int? sol_destino;
            private int? id_estableci;
   
            //para los cambios
            private int? chgsoli;

            
            private int? chgrepresoli;

            

            //fin de la modificacion
            
            public SolicitudInsertParam()
            {
            }

            public SolicitudInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitudInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public string Codiformato
            {
                get { return codiformato; }
                set { this.codiformato = value; }
            }

            public string Tipodoc
            {
                get { return tipodoc; }
                set { this.tipodoc = value; }
            }

            public string Numedoc
            {
                get { return numedoc; }
                set { this.numedoc = value; }
            }

            public int? Idperssoli
            {
                get { return idperssoli; }
                set { this.idperssoli = value; }
            }

            public int? Idpersrepr
            {
                get { return idpersrepr; }
                set { this.idpersrepr = value; }
            }

            public int? Idemprext
            {
                get { return idemprext; }
                set { this.idemprext = value; }
            }

            public int? Idpersalma
            {
                get { return idpersalma; }
                set { this.idpersalma = value; }
            }

            public int? Idpersrepralma
            {
                get { return idpersrepralma; }
                set { this.idpersrepralma = value; }
            }

            public DateTime? Fechrecepcion
            {
                get { return fechrecepcion; }
                set { this.fechrecepcion = value; }
            }

            public int? Idperslab
            {
                get { return idperslab; }
                set { this.idperslab = value; }
            }

            public int? Idpersperlab
            {
                get { return idpersperlab; }
                set { this.idpersperlab = value; }
            }

            //modificado por CESAR BOCANEGRA
            public int? Id_expedidor
            {
                get { return id_expedidor; }
                set { id_expedidor = value; }
            }

            public int? Id_destina
            {
                get { return id_destina; }
                set { id_destina = value; }
            }

            public int? Sol_destino
            {
                get { return sol_destino; }
                set { sol_destino = value; }
            }

            public int? Id_estableci
            {
                get { return id_estableci; }
                set { id_estableci = value; }
            }

            public int? Chgsoli
            {
                get { return chgsoli; }
                set { chgsoli = value; }
            }

            public int? Chgrepresoli
            {
                get { return chgrepresoli; }
                set { chgrepresoli = value; }
            }

            //fin de la modificacion
            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }


        public class SolicitudEspecificacionInsertParam
        {

            private int? idsolicitud;
            private int? idversion;
            private string reinscripcion;
            private string drano;
            private string drnro;
            private string suceano;
            private string sucenro;
            private string certificado;
            private string expediente;

            private string tcambempresa;
            private string tcambrepresentante;
            private string tcambalmacenamiento;
            private string tcambdenominacion;
            private string tcambenvase;
            private string tcambformulacion;
            private string tcambcancelacion;

            // MODIFICADO POR CESAR BOCANEGRA
            //private string idioma;

            private JSONArray idioma;

            


            
            //FIN DE LA MODIFICACION


            public SolicitudEspecificacionInsertParam()
            {
            }

            public SolicitudEspecificacionInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitudEspecificacionInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }


            public string Reinscripcion
            {
                get { return reinscripcion; }
                set { reinscripcion = value; }
            }

            public string Drano
            {
                get { return drano; }
                set { this.drano = value; }
            }

            public string Drnro
            {
                get { return drnro; }
                set { this.drnro = value; }
            }

            public string Suceano
            {
                get { return suceano; }
                set { this.suceano = value; }
            }

            public string Sucenro
            {
                get { return sucenro; }
                set { this.sucenro = value; }
            }

            public string Certificado
            {
                get { return certificado; }
                set { this.certificado = value; }
            }

            public string Expediente
            {
                get { return expediente; }
                set { this.expediente = value; }
            }

            public string Tcambempresa
            {
                get { return tcambempresa; }
                set { tcambempresa = value; }
            }


            public string Tcambrepresentante
            {
                get { return tcambrepresentante; }
                set { tcambrepresentante = value; }
            }


            public string Tcambalmacenamiento
            {
                get { return tcambalmacenamiento; }
                set { tcambalmacenamiento = value; }
            }

            public string Tcambdenominacion
            {
                get { return tcambdenominacion; }
                set { tcambdenominacion = value; }
            }


            public string Tcambenvase
            {
                get { return tcambenvase; }
                set { tcambenvase = value; }
            }


            public string Tcambformulacion
            {
                get { return tcambformulacion; }
                set { tcambformulacion = value; }
            }


            public string Tcambcancelacion
            {
                get { return tcambcancelacion; }
                set { tcambcancelacion = value; }
            }


            //MODIFICADO POR CESAR BOCANEGRA
            /*
            public string Idioma
            {
                get { return idioma; }
                set { idioma = value; }
            }
             */

            public JSONArray Idioma
            {
                get { return idioma; }
                set { idioma = value; }
            }
            //FIN DE LA MODIFICACION



            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }





        public class SolicitudAmpliadoInsertParam
        {

            private int? idsolicitud;
            private int? idversion;
            private string drano;


            public SolicitudAmpliadoInsertParam()
            {
            }

            public SolicitudAmpliadoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public SolicitudAmpliadoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public string Drano
            {
                get { return drano; }
                set { this.drano = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }






        public class LaboratorioCertificadoInsertParam
        {
            private int? idsolicitud;
            private int? idversion;
            private int? laboratorioacreditadoitem;
            private int? idlaboratorioacreditadotipo;
            private int? ididlaboratorioacreditado;
            private string nombre;

            public LaboratorioCertificadoInsertParam()
            {
            }

            public LaboratorioCertificadoInsertParam(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public LaboratorioCertificadoInsertParam(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud
            {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion
            {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public int? Laboratorioacreditadoitem
            {
                get { return laboratorioacreditadoitem; }
                set { this.laboratorioacreditadoitem = value; }
            }

            public int? IDLaboratorioAcreditadoTipo
            {
                get { return idlaboratorioacreditadotipo; }
                set { this.idlaboratorioacreditadotipo = value; }
            }

            public int? IDIDLaboratorioAcreditado
            {
                get { return ididlaboratorioacreditado; }
                set { this.ididlaboratorioacreditado = value; }
            }

            public string Nombre
            {
                get { return nombre; }
                set { this.nombre = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map)
            {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json)
            {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

    }
}
